﻿///////////////////////////////////////////////////////////////
// This is generated code. If you modify this code, be aware
// of the fact that when you re-generate the code, your changes
// are lost. If you want to keep your changes, make this file read-only
// when you have finished your changes, however it is recommended that
// you inherit from this class to extend the functionality of this generated
// class or you modify / extend the templates used to generate this code.
//////////////////////////////////////////////////////////////
// Code is generated using LLBLGen Pro version: 1.0.2005.1
// Code is generated on: Friday, March 07, 2008 3:18:12 PM
// Code is generated using templates: C# template set for SqlServer (1.0.2005.1)
// Templates vendor: Solutions Design.
// Templates version: 1.0.2005.1.111705
//////////////////////////////////////////////////////////////
using System;
using System.ComponentModel;
using System.Collections;
using System.Runtime.Serialization;
using System.Data;
using System.Xml.Serialization;

using RPSDAL;
using RPSDAL.FactoryClasses;
using RPSDAL.DaoClasses;
using RPSDAL.RelationClasses;
using RPSDAL.ValidatorClasses;
using RPSDAL.HelperClasses;
using RPSDAL.CollectionClasses;

using SD.LLBLGen.Pro.ORMSupportClasses;

namespace RPSDAL.EntityClasses
{
	
	// __LLBLGENPRO_USER_CODE_REGION_START AdditionalNamespaces
	// __LLBLGENPRO_USER_CODE_REGION_END
	
	/// <summary>Entity base class which represents the base class for the entity 'Contact'.<br/><br/>
	/// 
	/// </summary>
	[Serializable]
	public abstract partial class ContactEntityBase : EntityBase, ISerializable
		// __LLBLGENPRO_USER_CODE_REGION_START AdditionalInterfaces
		// __LLBLGENPRO_USER_CODE_REGION_END
			
	{
		#region Class Member Declarations
		private RPSDAL.CollectionClasses.BusinessRuleMailedContactCollection	_businessRuleMailedContact;
		private bool	_alwaysFetchBusinessRuleMailedContact, _alreadyFetchedBusinessRuleMailedContact;
		private RPSDAL.CollectionClasses.ContactFieldCollection	_contactField;
		private bool	_alwaysFetchContactField, _alreadyFetchedContactField;
		private RPSDAL.CollectionClasses.ContactFileCollection	_contactFile;
		private bool	_alwaysFetchContactFile, _alreadyFetchedContactFile;
		private RPSDAL.CollectionClasses.ContactGroupMemberCollection	_contactGroupMember;
		private bool	_alwaysFetchContactGroupMember, _alreadyFetchedContactGroupMember;
		private RPSDAL.CollectionClasses.ContactHistoryCollection	_contactHistory;
		private bool	_alwaysFetchContactHistory, _alreadyFetchedContactHistory;
		private RPSDAL.CollectionClasses.LetterCollection	_letter;
		private bool	_alwaysFetchLetter, _alreadyFetchedLetter;
		private RPSDAL.CollectionClasses.CallCollection	_call;
		private bool	_alwaysFetchCall, _alreadyFetchedCall;
		private RPSDAL.CollectionClasses.BusinessRuleCollection _businessRuleCollectionViaBusinessRuleMailedContact;
		private bool	_alwaysFetchBusinessRuleCollectionViaBusinessRuleMailedContact, _alreadyFetchedBusinessRuleCollectionViaBusinessRuleMailedContact;
		private RPSDAL.CollectionClasses.ContactPageFieldCollection _contactPageFieldCollectionViaContactField;
		private bool	_alwaysFetchContactPageFieldCollectionViaContactField, _alreadyFetchedContactPageFieldCollectionViaContactField;
		private RPSDAL.CollectionClasses.ContactGroupCollection _contactGroupCollectionViaContactGroupMember;
		private bool	_alwaysFetchContactGroupCollectionViaContactGroupMember, _alreadyFetchedContactGroupCollectionViaContactGroupMember;
		private RPSDAL.CollectionClasses.BusinessRuleCollection _businessRuleCollectionViaContactHistory;
		private bool	_alwaysFetchBusinessRuleCollectionViaContactHistory, _alreadyFetchedBusinessRuleCollectionViaContactHistory;
		private RPSDAL.CollectionClasses.LetterCollection _letterCollectionViaContactHistory;
		private bool	_alwaysFetchLetterCollectionViaContactHistory, _alreadyFetchedLetterCollectionViaContactHistory;
		private RPSDAL.CollectionClasses.BusinessRuleCollection _businessRuleCollectionViaLetter;
		private bool	_alwaysFetchBusinessRuleCollectionViaLetter, _alreadyFetchedBusinessRuleCollectionViaLetter;
		private RPSDAL.CollectionClasses.BusinessRuleCollection _businessRuleCollectionViaCall;
		private bool	_alwaysFetchBusinessRuleCollectionViaCall, _alreadyFetchedBusinessRuleCollectionViaCall;
		private RPSDAL.CollectionClasses.UserCollection _userCollectionViaCall;
		private bool	_alwaysFetchUserCollectionViaCall, _alreadyFetchedUserCollectionViaCall;
		private RPSDAL.CollectionClasses.CallCollection _callCollectionViaContactHistory;
		private bool	_alwaysFetchCallCollectionViaContactHistory, _alreadyFetchedCallCollectionViaContactHistory;
		private ContactTypeEntity _contactType;
		private bool	_alwaysFetchContactType, _alreadyFetchedContactType, _contactTypeReturnsNewIfNotFound;
		private UserEntity _user;
		private bool	_alwaysFetchUser, _alreadyFetchedUser, _userReturnsNewIfNotFound;

		private static Hashtable	_customProperties;
		private static Hashtable	_fieldsCustomProperties;
		
		// __LLBLGENPRO_USER_CODE_REGION_START PrivateMembers
		// __LLBLGENPRO_USER_CODE_REGION_END
		
		#endregion

		#region DataBinding Change Event Handler Declarations
		/// <summary>Event which is thrown when ContactId changes value. Databinding related.</summary>
		public event EventHandler ContactIdChanged;
		/// <summary>Event which is thrown when ContactTypeId changes value. Databinding related.</summary>
		public event EventHandler ContactTypeIdChanged;
		/// <summary>Event which is thrown when Name changes value. Databinding related.</summary>
		public event EventHandler NameChanged;
		/// <summary>Event which is thrown when EmailAddress changes value. Databinding related.</summary>
		public event EventHandler EmailAddressChanged;
		/// <summary>Event which is thrown when MailAddress changes value. Databinding related.</summary>
		public event EventHandler MailAddressChanged;
		/// <summary>Event which is thrown when MailState changes value. Databinding related.</summary>
		public event EventHandler MailStateChanged;
		/// <summary>Event which is thrown when MailCity changes value. Databinding related.</summary>
		public event EventHandler MailCityChanged;
		/// <summary>Event which is thrown when MailZip changes value. Databinding related.</summary>
		public event EventHandler MailZipChanged;
		/// <summary>Event which is thrown when MailCountry changes value. Databinding related.</summary>
		public event EventHandler MailCountryChanged;
		/// <summary>Event which is thrown when Phone changes value. Databinding related.</summary>
		public event EventHandler PhoneChanged;
		/// <summary>Event which is thrown when MobilePhone changes value. Databinding related.</summary>
		public event EventHandler MobilePhoneChanged;
		/// <summary>Event which is thrown when Fax changes value. Databinding related.</summary>
		public event EventHandler FaxChanged;
		/// <summary>Event which is thrown when ContactVisitDate changes value. Databinding related.</summary>
		public event EventHandler ContactVisitDateChanged;
		/// <summary>Event which is thrown when Active changes value. Databinding related.</summary>
		public event EventHandler ActiveChanged;
		/// <summary>Event which is thrown when UserId changes value. Databinding related.</summary>
		public event EventHandler UserIdChanged;
		/// <summary>Event which is thrown when SendNewsletter changes value. Databinding related.</summary>
		public event EventHandler SendNewsletterChanged;

		#endregion
		
		/// <summary>Static CTor for setting up custom property hashtables. Is executed before the first instance of this entity class or derived classes is constructed. </summary>
		static ContactEntityBase()
		{
			SetupCustomPropertyHashtables();
		}

		/// <summary>CTor</summary>
		public ContactEntityBase()
		{
			InitClassEmpty(new PropertyDescriptorFactory(), CreateEntityFactoryInstance(), CreateValidator());
		}

	
		/// <summary>CTor</summary>
		/// <param name="contactId">PK value for Contact which data should be fetched into this Contact object</param>
		public ContactEntityBase(System.Int32 contactId)
		{
			InitClassFetch(contactId, CreateValidator(), new PropertyDescriptorFactory(), CreateEntityFactoryInstance(), null);
		}

		/// <summary>CTor</summary>
		/// <param name="contactId">PK value for Contact which data should be fetched into this Contact object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		public ContactEntityBase(System.Int32 contactId, IPrefetchPath prefetchPathToUse)
		{
			InitClassFetch(contactId, CreateValidator(), new PropertyDescriptorFactory(), CreateEntityFactoryInstance(), prefetchPathToUse);
		}

		/// <summary>CTor</summary>
		/// <param name="contactId">PK value for Contact which data should be fetched into this Contact object</param>
		/// <param name="validator">The custom validator object for this ContactEntity</param>
		public ContactEntityBase(System.Int32 contactId, ContactValidator validator)
		{
			InitClassFetch(contactId, validator, new PropertyDescriptorFactory(), CreateEntityFactoryInstance(), null);
		}

		/// <summary>CTor</summary>
		/// <param name="contactId">PK value for Contact which data should be fetched into this Contact object</param>
		/// <param name="validator">The custom validator object for this ContactEntity</param>
		/// <param name="propertyDescriptorFactoryToUse">PropertyDescriptor factory to use in GetItemProperties method of contained collections. Complex databinding related.</param>
		/// <param name="entityFactoryToUse">The EntityFactory to use when creating entity objects during a GetMulti() call.</param>
		public ContactEntityBase(System.Int32 contactId, ContactValidator validator, IPropertyDescriptorFactory propertyDescriptorFactoryToUse, IEntityFactory entityFactoryToUse)
		{
			InitClassFetch(contactId, validator, propertyDescriptorFactoryToUse, entityFactoryToUse, null);
		}
	

		/// <summary>CTor</summary>
		/// <param name="propertyDescriptorFactoryToUse">PropertyDescriptor factory to use in GetItemProperties method of contained collections. Complex databinding related.</param>
		/// <param name="entityFactoryToUse">The EntityFactory to use when creating entity objects during a GetMulti() call.</param>
		public ContactEntityBase(IPropertyDescriptorFactory propertyDescriptorFactoryToUse, IEntityFactory entityFactoryToUse)
		{
			InitClassEmpty(propertyDescriptorFactoryToUse, entityFactoryToUse, CreateValidator());
		}

		/// <summary>Protected CTor for deserialization</summary>
		/// <param name="info"></param>
		/// <param name="context"></param>
		protected ContactEntityBase(SerializationInfo info, StreamingContext context) : base(info, context)
		{
			_businessRuleMailedContact = (RPSDAL.CollectionClasses.BusinessRuleMailedContactCollection)info.GetValue("_businessRuleMailedContact", typeof(RPSDAL.CollectionClasses.BusinessRuleMailedContactCollection));
			_alwaysFetchBusinessRuleMailedContact = info.GetBoolean("_alwaysFetchBusinessRuleMailedContact");
			_alreadyFetchedBusinessRuleMailedContact = info.GetBoolean("_alreadyFetchedBusinessRuleMailedContact");
			_contactField = (RPSDAL.CollectionClasses.ContactFieldCollection)info.GetValue("_contactField", typeof(RPSDAL.CollectionClasses.ContactFieldCollection));
			_alwaysFetchContactField = info.GetBoolean("_alwaysFetchContactField");
			_alreadyFetchedContactField = info.GetBoolean("_alreadyFetchedContactField");
			_contactFile = (RPSDAL.CollectionClasses.ContactFileCollection)info.GetValue("_contactFile", typeof(RPSDAL.CollectionClasses.ContactFileCollection));
			_alwaysFetchContactFile = info.GetBoolean("_alwaysFetchContactFile");
			_alreadyFetchedContactFile = info.GetBoolean("_alreadyFetchedContactFile");
			_contactGroupMember = (RPSDAL.CollectionClasses.ContactGroupMemberCollection)info.GetValue("_contactGroupMember", typeof(RPSDAL.CollectionClasses.ContactGroupMemberCollection));
			_alwaysFetchContactGroupMember = info.GetBoolean("_alwaysFetchContactGroupMember");
			_alreadyFetchedContactGroupMember = info.GetBoolean("_alreadyFetchedContactGroupMember");
			_contactHistory = (RPSDAL.CollectionClasses.ContactHistoryCollection)info.GetValue("_contactHistory", typeof(RPSDAL.CollectionClasses.ContactHistoryCollection));
			_alwaysFetchContactHistory = info.GetBoolean("_alwaysFetchContactHistory");
			_alreadyFetchedContactHistory = info.GetBoolean("_alreadyFetchedContactHistory");
			_letter = (RPSDAL.CollectionClasses.LetterCollection)info.GetValue("_letter", typeof(RPSDAL.CollectionClasses.LetterCollection));
			_alwaysFetchLetter = info.GetBoolean("_alwaysFetchLetter");
			_alreadyFetchedLetter = info.GetBoolean("_alreadyFetchedLetter");
			_call = (RPSDAL.CollectionClasses.CallCollection)info.GetValue("_call", typeof(RPSDAL.CollectionClasses.CallCollection));
			_alwaysFetchCall = info.GetBoolean("_alwaysFetchCall");
			_alreadyFetchedCall = info.GetBoolean("_alreadyFetchedCall");
			_businessRuleCollectionViaBusinessRuleMailedContact = (RPSDAL.CollectionClasses.BusinessRuleCollection)info.GetValue("_businessRuleCollectionViaBusinessRuleMailedContact", typeof(RPSDAL.CollectionClasses.BusinessRuleCollection));
			_alwaysFetchBusinessRuleCollectionViaBusinessRuleMailedContact = info.GetBoolean("_alwaysFetchBusinessRuleCollectionViaBusinessRuleMailedContact");
			_alreadyFetchedBusinessRuleCollectionViaBusinessRuleMailedContact = info.GetBoolean("_alreadyFetchedBusinessRuleCollectionViaBusinessRuleMailedContact");
			_contactPageFieldCollectionViaContactField = (RPSDAL.CollectionClasses.ContactPageFieldCollection)info.GetValue("_contactPageFieldCollectionViaContactField", typeof(RPSDAL.CollectionClasses.ContactPageFieldCollection));
			_alwaysFetchContactPageFieldCollectionViaContactField = info.GetBoolean("_alwaysFetchContactPageFieldCollectionViaContactField");
			_alreadyFetchedContactPageFieldCollectionViaContactField = info.GetBoolean("_alreadyFetchedContactPageFieldCollectionViaContactField");
			_contactGroupCollectionViaContactGroupMember = (RPSDAL.CollectionClasses.ContactGroupCollection)info.GetValue("_contactGroupCollectionViaContactGroupMember", typeof(RPSDAL.CollectionClasses.ContactGroupCollection));
			_alwaysFetchContactGroupCollectionViaContactGroupMember = info.GetBoolean("_alwaysFetchContactGroupCollectionViaContactGroupMember");
			_alreadyFetchedContactGroupCollectionViaContactGroupMember = info.GetBoolean("_alreadyFetchedContactGroupCollectionViaContactGroupMember");
			_businessRuleCollectionViaContactHistory = (RPSDAL.CollectionClasses.BusinessRuleCollection)info.GetValue("_businessRuleCollectionViaContactHistory", typeof(RPSDAL.CollectionClasses.BusinessRuleCollection));
			_alwaysFetchBusinessRuleCollectionViaContactHistory = info.GetBoolean("_alwaysFetchBusinessRuleCollectionViaContactHistory");
			_alreadyFetchedBusinessRuleCollectionViaContactHistory = info.GetBoolean("_alreadyFetchedBusinessRuleCollectionViaContactHistory");
			_letterCollectionViaContactHistory = (RPSDAL.CollectionClasses.LetterCollection)info.GetValue("_letterCollectionViaContactHistory", typeof(RPSDAL.CollectionClasses.LetterCollection));
			_alwaysFetchLetterCollectionViaContactHistory = info.GetBoolean("_alwaysFetchLetterCollectionViaContactHistory");
			_alreadyFetchedLetterCollectionViaContactHistory = info.GetBoolean("_alreadyFetchedLetterCollectionViaContactHistory");
			_businessRuleCollectionViaLetter = (RPSDAL.CollectionClasses.BusinessRuleCollection)info.GetValue("_businessRuleCollectionViaLetter", typeof(RPSDAL.CollectionClasses.BusinessRuleCollection));
			_alwaysFetchBusinessRuleCollectionViaLetter = info.GetBoolean("_alwaysFetchBusinessRuleCollectionViaLetter");
			_alreadyFetchedBusinessRuleCollectionViaLetter = info.GetBoolean("_alreadyFetchedBusinessRuleCollectionViaLetter");
			_businessRuleCollectionViaCall = (RPSDAL.CollectionClasses.BusinessRuleCollection)info.GetValue("_businessRuleCollectionViaCall", typeof(RPSDAL.CollectionClasses.BusinessRuleCollection));
			_alwaysFetchBusinessRuleCollectionViaCall = info.GetBoolean("_alwaysFetchBusinessRuleCollectionViaCall");
			_alreadyFetchedBusinessRuleCollectionViaCall = info.GetBoolean("_alreadyFetchedBusinessRuleCollectionViaCall");
			_userCollectionViaCall = (RPSDAL.CollectionClasses.UserCollection)info.GetValue("_userCollectionViaCall", typeof(RPSDAL.CollectionClasses.UserCollection));
			_alwaysFetchUserCollectionViaCall = info.GetBoolean("_alwaysFetchUserCollectionViaCall");
			_alreadyFetchedUserCollectionViaCall = info.GetBoolean("_alreadyFetchedUserCollectionViaCall");
			_callCollectionViaContactHistory = (RPSDAL.CollectionClasses.CallCollection)info.GetValue("_callCollectionViaContactHistory", typeof(RPSDAL.CollectionClasses.CallCollection));
			_alwaysFetchCallCollectionViaContactHistory = info.GetBoolean("_alwaysFetchCallCollectionViaContactHistory");
			_alreadyFetchedCallCollectionViaContactHistory = info.GetBoolean("_alreadyFetchedCallCollectionViaContactHistory");
			_contactType = (ContactTypeEntity)info.GetValue("_contactType", typeof(ContactTypeEntity));
			if(_contactType!=null)
			{
				_contactType.AfterSave+=new EventHandler(OnEntityAfterSave);
			}
			_contactTypeReturnsNewIfNotFound = info.GetBoolean("_contactTypeReturnsNewIfNotFound");
			_alwaysFetchContactType = info.GetBoolean("_alwaysFetchContactType");
			_alreadyFetchedContactType = info.GetBoolean("_alreadyFetchedContactType");
			_user = (UserEntity)info.GetValue("_user", typeof(UserEntity));
			if(_user!=null)
			{
				_user.AfterSave+=new EventHandler(OnEntityAfterSave);
			}
			_userReturnsNewIfNotFound = info.GetBoolean("_userReturnsNewIfNotFound");
			_alwaysFetchUser = info.GetBoolean("_alwaysFetchUser");
			_alreadyFetchedUser = info.GetBoolean("_alreadyFetchedUser");

			
			// __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
			// __LLBLGENPRO_USER_CODE_REGION_END
			
		}

		
		/// <summary> Will perform post-ReadXml actions as well as the normal ReadXml() actions, performed by the base class.</summary>
		/// <param name="node">XmlNode with Xml data which should be read into this entity and its members. Node's root element is the root element of the entity's Xml data</param>
		public override void ReadXml(System.Xml.XmlNode node)
		{
			base.ReadXml (node);
			_alreadyFetchedBusinessRuleMailedContact = (_businessRuleMailedContact.Count > 0);
			_alreadyFetchedContactField = (_contactField.Count > 0);
			_alreadyFetchedContactFile = (_contactFile.Count > 0);
			_alreadyFetchedContactGroupMember = (_contactGroupMember.Count > 0);
			_alreadyFetchedContactHistory = (_contactHistory.Count > 0);
			_alreadyFetchedLetter = (_letter.Count > 0);
			_alreadyFetchedCall = (_call.Count > 0);
			_alreadyFetchedBusinessRuleCollectionViaBusinessRuleMailedContact = (_businessRuleCollectionViaBusinessRuleMailedContact.Count > 0);
			_alreadyFetchedContactPageFieldCollectionViaContactField = (_contactPageFieldCollectionViaContactField.Count > 0);
			_alreadyFetchedContactGroupCollectionViaContactGroupMember = (_contactGroupCollectionViaContactGroupMember.Count > 0);
			_alreadyFetchedBusinessRuleCollectionViaContactHistory = (_businessRuleCollectionViaContactHistory.Count > 0);
			_alreadyFetchedLetterCollectionViaContactHistory = (_letterCollectionViaContactHistory.Count > 0);
			_alreadyFetchedBusinessRuleCollectionViaLetter = (_businessRuleCollectionViaLetter.Count > 0);
			_alreadyFetchedBusinessRuleCollectionViaCall = (_businessRuleCollectionViaCall.Count > 0);
			_alreadyFetchedUserCollectionViaCall = (_userCollectionViaCall.Count > 0);
			_alreadyFetchedCallCollectionViaContactHistory = (_callCollectionViaContactHistory.Count > 0);
			_alreadyFetchedContactType = (_contactType != null);
			_alreadyFetchedUser = (_user != null);

		}


		/// <summary> Saves the Entity class to the persistent storage. It updates or inserts the entity, which depends if the entity was originally read from the 
		/// database. If the entity is new, an insert is done and the updateRestriction is ignored. If the entity is not new, the updateRestriction
		/// predicate is used to create an additional where clause (it will be added with AND) for the update query. This predicate can be used for
		/// concurrency checks, like checks on timestamp column values.</summary>
		/// <param name="updateRestriction">Predicate expression, meant for concurrency checks in an Update query. Will be ignored when the entity is new </param>
		/// <param name="recurse">When true, it will save all dirty objects referenced (directly or indirectly) by this entity also.</param>
		/// <returns>true if Save succeeded, false otherwise</returns>
		/// <remarks>Do not call this routine directly, use the overloaded version in a derived class as this version doesn't construct a
		/// local transaction during recursive save, this is done in the overloaded version in a derived class.</remarks>
		/// <exception cref="ORMQueryExecutionException">When an exception is caught during the save process. The caught exception is set as the
		/// inner exception. Encapsulation of database-related exceptions is necessary since these exceptions do not have a common exception framework implemented.</exception>
		public override bool Save(IPredicate updateRestriction, bool recurse)
		{
			bool transactionStartedInThisScope = false;
			Transaction transactionManager = null;

			if(recurse || ((this.LLBLGenProIsInHierarchyOfType==InheritanceHierarchyType.TargetPerEntity) && this.LLBLGenProIsSubType))
			{
				if(!base.ParticipatesInTransaction)
				{
					transactionManager = new Transaction(IsolationLevel.ReadCommitted, "SaveRecursively");
					transactionManager.Add(this);
					transactionStartedInThisScope=true;
				}
			}
			try
			{
				bool result = base.Save(updateRestriction, recurse);
				if(transactionStartedInThisScope)
				{
					transactionManager.Commit();
				}
				return result;
			}
			catch
			{
				if(transactionStartedInThisScope)
				{
					transactionManager.Rollback();
				}
				throw;
			}
			finally
			{
				if(transactionStartedInThisScope)
				{
					transactionManager.Dispose();
				}
			}
		}
		


		/// <summary> ISerializable member. Does custom serialization so event handlers do not get serialized.
		/// Serializes members of this entity class and uses the base class' implementation to serialize the rest.</summary>
		/// <param name="info"></param>
		/// <param name="context"></param>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override void GetObjectData(SerializationInfo info, StreamingContext context)
		{
			info.AddValue("_businessRuleMailedContact", _businessRuleMailedContact);
			info.AddValue("_alwaysFetchBusinessRuleMailedContact", _alwaysFetchBusinessRuleMailedContact);
			info.AddValue("_alreadyFetchedBusinessRuleMailedContact", _alreadyFetchedBusinessRuleMailedContact);
			info.AddValue("_contactField", _contactField);
			info.AddValue("_alwaysFetchContactField", _alwaysFetchContactField);
			info.AddValue("_alreadyFetchedContactField", _alreadyFetchedContactField);
			info.AddValue("_contactFile", _contactFile);
			info.AddValue("_alwaysFetchContactFile", _alwaysFetchContactFile);
			info.AddValue("_alreadyFetchedContactFile", _alreadyFetchedContactFile);
			info.AddValue("_contactGroupMember", _contactGroupMember);
			info.AddValue("_alwaysFetchContactGroupMember", _alwaysFetchContactGroupMember);
			info.AddValue("_alreadyFetchedContactGroupMember", _alreadyFetchedContactGroupMember);
			info.AddValue("_contactHistory", _contactHistory);
			info.AddValue("_alwaysFetchContactHistory", _alwaysFetchContactHistory);
			info.AddValue("_alreadyFetchedContactHistory", _alreadyFetchedContactHistory);
			info.AddValue("_letter", _letter);
			info.AddValue("_alwaysFetchLetter", _alwaysFetchLetter);
			info.AddValue("_alreadyFetchedLetter", _alreadyFetchedLetter);
			info.AddValue("_call", _call);
			info.AddValue("_alwaysFetchCall", _alwaysFetchCall);
			info.AddValue("_alreadyFetchedCall", _alreadyFetchedCall);
			info.AddValue("_businessRuleCollectionViaBusinessRuleMailedContact", _businessRuleCollectionViaBusinessRuleMailedContact);
			info.AddValue("_alwaysFetchBusinessRuleCollectionViaBusinessRuleMailedContact", _alwaysFetchBusinessRuleCollectionViaBusinessRuleMailedContact);
			info.AddValue("_alreadyFetchedBusinessRuleCollectionViaBusinessRuleMailedContact", _alreadyFetchedBusinessRuleCollectionViaBusinessRuleMailedContact);
			info.AddValue("_contactPageFieldCollectionViaContactField", _contactPageFieldCollectionViaContactField);
			info.AddValue("_alwaysFetchContactPageFieldCollectionViaContactField", _alwaysFetchContactPageFieldCollectionViaContactField);
			info.AddValue("_alreadyFetchedContactPageFieldCollectionViaContactField", _alreadyFetchedContactPageFieldCollectionViaContactField);
			info.AddValue("_contactGroupCollectionViaContactGroupMember", _contactGroupCollectionViaContactGroupMember);
			info.AddValue("_alwaysFetchContactGroupCollectionViaContactGroupMember", _alwaysFetchContactGroupCollectionViaContactGroupMember);
			info.AddValue("_alreadyFetchedContactGroupCollectionViaContactGroupMember", _alreadyFetchedContactGroupCollectionViaContactGroupMember);
			info.AddValue("_businessRuleCollectionViaContactHistory", _businessRuleCollectionViaContactHistory);
			info.AddValue("_alwaysFetchBusinessRuleCollectionViaContactHistory", _alwaysFetchBusinessRuleCollectionViaContactHistory);
			info.AddValue("_alreadyFetchedBusinessRuleCollectionViaContactHistory", _alreadyFetchedBusinessRuleCollectionViaContactHistory);
			info.AddValue("_letterCollectionViaContactHistory", _letterCollectionViaContactHistory);
			info.AddValue("_alwaysFetchLetterCollectionViaContactHistory", _alwaysFetchLetterCollectionViaContactHistory);
			info.AddValue("_alreadyFetchedLetterCollectionViaContactHistory", _alreadyFetchedLetterCollectionViaContactHistory);
			info.AddValue("_businessRuleCollectionViaLetter", _businessRuleCollectionViaLetter);
			info.AddValue("_alwaysFetchBusinessRuleCollectionViaLetter", _alwaysFetchBusinessRuleCollectionViaLetter);
			info.AddValue("_alreadyFetchedBusinessRuleCollectionViaLetter", _alreadyFetchedBusinessRuleCollectionViaLetter);
			info.AddValue("_businessRuleCollectionViaCall", _businessRuleCollectionViaCall);
			info.AddValue("_alwaysFetchBusinessRuleCollectionViaCall", _alwaysFetchBusinessRuleCollectionViaCall);
			info.AddValue("_alreadyFetchedBusinessRuleCollectionViaCall", _alreadyFetchedBusinessRuleCollectionViaCall);
			info.AddValue("_userCollectionViaCall", _userCollectionViaCall);
			info.AddValue("_alwaysFetchUserCollectionViaCall", _alwaysFetchUserCollectionViaCall);
			info.AddValue("_alreadyFetchedUserCollectionViaCall", _alreadyFetchedUserCollectionViaCall);
			info.AddValue("_callCollectionViaContactHistory", _callCollectionViaContactHistory);
			info.AddValue("_alwaysFetchCallCollectionViaContactHistory", _alwaysFetchCallCollectionViaContactHistory);
			info.AddValue("_alreadyFetchedCallCollectionViaContactHistory", _alreadyFetchedCallCollectionViaContactHistory);
			info.AddValue("_contactType", _contactType);
			info.AddValue("_contactTypeReturnsNewIfNotFound", _contactTypeReturnsNewIfNotFound);
			info.AddValue("_alwaysFetchContactType", _alwaysFetchContactType);
			info.AddValue("_alreadyFetchedContactType", _alreadyFetchedContactType);
			info.AddValue("_user", _user);
			info.AddValue("_userReturnsNewIfNotFound", _userReturnsNewIfNotFound);
			info.AddValue("_alwaysFetchUser", _alwaysFetchUser);
			info.AddValue("_alreadyFetchedUser", _alreadyFetchedUser);

			
			// __LLBLGENPRO_USER_CODE_REGION_START GetObjectInfo
			// __LLBLGENPRO_USER_CODE_REGION_END
			
			base.GetObjectData(info, context);
		}
		
		/// <summary> Sets the related entity property to the entity specified. If the property is a collection, it will add the entity specified to that collection.</summary>
		/// <param name="propertyName">Name of the property.</param>
		/// <param name="entity">Entity to set as an related entity</param>
		/// <remarks>Used by prefetch path logic.</remarks>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override void SetRelatedEntityProperty(string propertyName, IEntityCore entity)
		{
			switch(propertyName)
			{
				case "ContactType":
					_alreadyFetchedContactType = true;
					this.ContactType = (ContactTypeEntity)entity;
					break;
				case "User":
					_alreadyFetchedUser = true;
					this.User = (UserEntity)entity;
					break;
				case "BusinessRuleMailedContact":
					_alreadyFetchedBusinessRuleMailedContact = true;
					if(entity!=null)
					{
						this.BusinessRuleMailedContact.Add((BusinessRuleMailedContactEntity)entity);
					}
					break;
				case "ContactField":
					_alreadyFetchedContactField = true;
					if(entity!=null)
					{
						this.ContactField.Add((ContactFieldEntity)entity);
					}
					break;
				case "ContactFile":
					_alreadyFetchedContactFile = true;
					if(entity!=null)
					{
						this.ContactFile.Add((ContactFileEntity)entity);
					}
					break;
				case "ContactGroupMember":
					_alreadyFetchedContactGroupMember = true;
					if(entity!=null)
					{
						this.ContactGroupMember.Add((ContactGroupMemberEntity)entity);
					}
					break;
				case "ContactHistory":
					_alreadyFetchedContactHistory = true;
					if(entity!=null)
					{
						this.ContactHistory.Add((ContactHistoryEntity)entity);
					}
					break;
				case "Letter":
					_alreadyFetchedLetter = true;
					if(entity!=null)
					{
						this.Letter.Add((LetterEntity)entity);
					}
					break;
				case "Call":
					_alreadyFetchedCall = true;
					if(entity!=null)
					{
						this.Call.Add((CallEntity)entity);
					}
					break;
				case "BusinessRuleCollectionViaBusinessRuleMailedContact":
					_alreadyFetchedBusinessRuleCollectionViaBusinessRuleMailedContact = true;
					if(entity!=null)
					{
						this.BusinessRuleCollectionViaBusinessRuleMailedContact.Add((BusinessRuleEntity)entity);
					}
					break;
				case "ContactPageFieldCollectionViaContactField":
					_alreadyFetchedContactPageFieldCollectionViaContactField = true;
					if(entity!=null)
					{
						this.ContactPageFieldCollectionViaContactField.Add((ContactPageFieldEntity)entity);
					}
					break;
				case "ContactGroupCollectionViaContactGroupMember":
					_alreadyFetchedContactGroupCollectionViaContactGroupMember = true;
					if(entity!=null)
					{
						this.ContactGroupCollectionViaContactGroupMember.Add((ContactGroupEntity)entity);
					}
					break;
				case "BusinessRuleCollectionViaContactHistory":
					_alreadyFetchedBusinessRuleCollectionViaContactHistory = true;
					if(entity!=null)
					{
						this.BusinessRuleCollectionViaContactHistory.Add((BusinessRuleEntity)entity);
					}
					break;
				case "LetterCollectionViaContactHistory":
					_alreadyFetchedLetterCollectionViaContactHistory = true;
					if(entity!=null)
					{
						this.LetterCollectionViaContactHistory.Add((LetterEntity)entity);
					}
					break;
				case "BusinessRuleCollectionViaLetter":
					_alreadyFetchedBusinessRuleCollectionViaLetter = true;
					if(entity!=null)
					{
						this.BusinessRuleCollectionViaLetter.Add((BusinessRuleEntity)entity);
					}
					break;
				case "BusinessRuleCollectionViaCall":
					_alreadyFetchedBusinessRuleCollectionViaCall = true;
					if(entity!=null)
					{
						this.BusinessRuleCollectionViaCall.Add((BusinessRuleEntity)entity);
					}
					break;
				case "UserCollectionViaCall":
					_alreadyFetchedUserCollectionViaCall = true;
					if(entity!=null)
					{
						this.UserCollectionViaCall.Add((UserEntity)entity);
					}
					break;
				case "CallCollectionViaContactHistory":
					_alreadyFetchedCallCollectionViaContactHistory = true;
					if(entity!=null)
					{
						this.CallCollectionViaContactHistory.Add((CallEntity)entity);
					}
					break;

				default:

					break;
			}
		}

		/// <summary> Sets the internal parameter related to the fieldname passed to the instance relatedEntity. </summary>
		/// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
		/// <param name="fieldName">Name of field mapped onto the relation which resolves in the instance relatedEntity</param>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override void SetRelatedEntity(IEntity relatedEntity, string fieldName)
		{
			switch(fieldName)
			{
				case "ContactType":
					SetupSyncContactType(relatedEntity);
					break;
				case "User":
					SetupSyncUser(relatedEntity);
					break;
				case "BusinessRuleMailedContact":
					_businessRuleMailedContact.Add(relatedEntity);
					break;
				case "ContactField":
					_contactField.Add(relatedEntity);
					break;
				case "ContactFile":
					_contactFile.Add(relatedEntity);
					break;
				case "ContactGroupMember":
					_contactGroupMember.Add(relatedEntity);
					break;
				case "ContactHistory":
					_contactHistory.Add(relatedEntity);
					break;
				case "Letter":
					_letter.Add(relatedEntity);
					break;
				case "Call":
					_call.Add(relatedEntity);
					break;

				default:

					break;
			}
		}
		
		/// <summary> Unsets the internal parameter related to the fieldname passed to the instance relatedEntity. Reverses the actions taken by SetRelatedEntity() </summary>
		/// <param name="relatedEntity">Instance to unset as the related entity of type entityType</param>
		/// <param name="fieldName">Name of field mapped onto the relation which resolves in the instance relatedEntity</param>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override void UnsetRelatedEntity(IEntity relatedEntity, string fieldName)
		{
			switch(fieldName)
			{
				case "ContactType":
					DesetupSyncContactType(false);
					break;
				case "User":
					DesetupSyncUser(false);
					break;
				case "BusinessRuleMailedContact":
					_businessRuleMailedContact.Remove(relatedEntity);
					break;
				case "ContactField":
					_contactField.Remove(relatedEntity);
					break;
				case "ContactFile":
					_contactFile.Remove(relatedEntity);
					break;
				case "ContactGroupMember":
					_contactGroupMember.Remove(relatedEntity);
					break;
				case "ContactHistory":
					_contactHistory.Remove(relatedEntity);
					break;
				case "Letter":
					_letter.Remove(relatedEntity);
					break;
				case "Call":
					_call.Remove(relatedEntity);
					break;

				default:

					break;
			}
		}

		/// <summary> Gets a collection of related entities referenced by this entity which depend on this entity (this entity is the PK side of their FK fields). These
		/// entities will have to be persisted after this entity during a recursive save.</summary>
		/// <returns>Collection with 0 or more IEntity objects, referenced by this entity</returns>
		public override ArrayList GetDependingRelatedEntities()
		{
			ArrayList toReturn = new ArrayList();


			return toReturn;
		}
		
		/// <summary> Gets a collection of related entities referenced by this entity which this entity depends on (this entity is the FK side of their PK fields). These
		/// entities will have to be persisted before this entity during a recursive save.</summary>
		/// <returns>Collection with 0 or more IEntity objects, referenced by this entity</returns>
		public override ArrayList GetDependentRelatedEntities()
		{
			ArrayList toReturn = new ArrayList();
			if(_contactType!=null)
			{
				toReturn.Add(_contactType);
			}
			if(_user!=null)
			{
				toReturn.Add(_user);
			}


			return toReturn;
		}
		
		/// <summary> Gets an ArrayList of all entity collections stored as member variables in this entity. The contents of the ArrayList is
		/// used by the DataAccessAdapter to perform recursive saves. Only 1:n related collections are returned.</summary>
		/// <returns>Collection with 0 or more IEntityCollection objects, referenced by this entity</returns>
		public override ArrayList GetMemberEntityCollections()
		{
			ArrayList toReturn = new ArrayList();
			toReturn.Add(_businessRuleMailedContact);
			toReturn.Add(_contactField);
			toReturn.Add(_contactFile);
			toReturn.Add(_contactGroupMember);
			toReturn.Add(_contactHistory);
			toReturn.Add(_letter);
			toReturn.Add(_call);

			return toReturn;
		}

		

		

		/// <summary> Fetches the contents of this entity from the persistent storage using the primary key.</summary>
		/// <param name="contactId">PK value for Contact which data should be fetched into this Contact object</param>
		/// <returns>True if succeeded, false otherwise.</returns>
		public bool FetchUsingPK(System.Int32 contactId)
		{
			return FetchUsingPK(contactId, null, null);
		}

		/// <summary> Fetches the contents of this entity from the persistent storage using the primary key.</summary>
		/// <param name="contactId">PK value for Contact which data should be fetched into this Contact object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		/// <returns>True if succeeded, false otherwise.</returns>
		public bool FetchUsingPK(System.Int32 contactId, IPrefetchPath prefetchPathToUse)
		{
			return FetchUsingPK(contactId, prefetchPathToUse, null);
		}

		/// <summary> Fetches the contents of this entity from the persistent storage using the primary key.</summary>
		/// <param name="contactId">PK value for Contact which data should be fetched into this Contact object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		/// <param name="contextToUse">The context to add the entity to if the fetch was succesful. </param>
		/// <returns>True if succeeded, false otherwise.</returns>
		public bool FetchUsingPK(System.Int32 contactId, IPrefetchPath prefetchPathToUse, Context contextToUse)
		{
			return Fetch(contactId, prefetchPathToUse, contextToUse);
		}

		/// <summary> Refetches the Entity from the persistent storage. Refetch is used to re-load an Entity which is marked "Out-of-sync", due to a save action. 
		/// Refetching an empty Entity has no effect. </summary>
		/// <returns>true if Refetch succeeded, false otherwise</returns>
		public override bool Refetch()
		{
			return Fetch(this.ContactId, null, null);
		}


		/// <summary> Deletes the Entity from the persistent storage. This method succeeds also when the Entity is not present.</summary>
		/// <param name="deleteRestriction">Predicate expression, meant for concurrency checks in a delete query. Overrules the predicate returned by a set ConcurrencyPredicateFactory object.</param>
		/// <returns>true if Delete succeeded, false otherwise</returns>
		public override bool Delete(IPredicate deleteRestriction)
		{
			bool transactionStartedInThisScope = false;
			Transaction transactionManager = null;
			if((this.LLBLGenProIsInHierarchyOfType==InheritanceHierarchyType.TargetPerEntity) && this.LLBLGenProIsSubType)
			{
				if(!base.ParticipatesInTransaction)
				{
					transactionManager = new Transaction(IsolationLevel.ReadCommitted, "DeleteEntity");
					transactionManager.Add(this);
					transactionStartedInThisScope=true;
				}
			}
			try
			{
				OnDelete();
				IDao dao = CreateDAOInstance();
				bool wasSuccesful = dao.DeleteExisting(base.Fields, base.Transaction, deleteRestriction);
				if(wasSuccesful)
				{
					base.Delete(deleteRestriction);
				}
				if(transactionStartedInThisScope)
				{
					transactionManager.Commit();
				}
				return wasSuccesful;
			}
			catch
			{
				if(transactionStartedInThisScope)
				{
					transactionManager.Rollback();
				}
				throw;
			}
			finally
			{
				if(transactionStartedInThisScope)
				{
					transactionManager.Dispose();
				}
				OnDeleteComplete();
			}
		}

		/// <summary> Returns true if the original value for the field with the fieldIndex passed in, read from the persistent storage was NULL, false otherwise.
		/// Should not be used for testing if the current value is NULL, use <see cref="TestCurrentFieldValueForNull"/> for that.</summary>
		/// <param name="fieldIndex">Index of the field to test if that field was NULL in the persistent storage</param>
		/// <returns>true if the field with the passed in index was NULL in the persistent storage, false otherwise</returns>
		public bool TestOriginalFieldValueForNull(ContactFieldIndex fieldIndex)
		{
			return base.Fields[(int)fieldIndex].IsNull;
		}
		
		/// <summary>Returns true if the current value for the field with the fieldIndex passed in represents null/not defined, false otherwise.
		/// Should not be used for testing if the original value (read from the db) is NULL</summary>
		/// <param name="fieldIndex">Index of the field to test if its currentvalue is null/undefined</param>
		/// <returns>true if the field's value isn't defined yet, false otherwise</returns>
		public bool TestCurrentFieldValueForNull(ContactFieldIndex fieldIndex)
		{
			return base.CheckIfCurrentFieldValueIsNull((int)fieldIndex);
		}
		
		/// <summary>Determines whether this entity is a subType of the entity represented by the passed in enum value, which represents a value in the EntityType enum</summary>
		/// <param name="typeOfEntity">Type of entity.</param>
		/// <returns>true if the passed in type is a supertype of this entity, otherwise false</returns>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override bool CheckIfIsSubTypeOf(int typeOfEntity)
		{
			return InheritanceInfoProviderSingleton.GetInstance().CheckIfIsSubTypeOf("ContactEntity", ((RPSDAL.EntityType)typeOfEntity).ToString());
		}


		/// <summary> Retrieves all related entities of type 'BusinessRuleMailedContactEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'BusinessRuleMailedContactEntity'</returns>
		public RPSDAL.CollectionClasses.BusinessRuleMailedContactCollection GetMultiBusinessRuleMailedContact(bool forceFetch)
		{
			return GetMultiBusinessRuleMailedContact(forceFetch, _businessRuleMailedContact.EntityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'BusinessRuleMailedContactEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of type 'BusinessRuleMailedContactEntity'</returns>
		public RPSDAL.CollectionClasses.BusinessRuleMailedContactCollection GetMultiBusinessRuleMailedContact(bool forceFetch, IPredicateExpression filter)
		{
			return GetMultiBusinessRuleMailedContact(forceFetch, _businessRuleMailedContact.EntityFactoryToUse, filter);
		}

		/// <summary> Retrieves all related entities of type 'BusinessRuleMailedContactEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public RPSDAL.CollectionClasses.BusinessRuleMailedContactCollection GetMultiBusinessRuleMailedContact(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
			return GetMultiBusinessRuleMailedContact(forceFetch, entityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'BusinessRuleMailedContactEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public virtual RPSDAL.CollectionClasses.BusinessRuleMailedContactCollection GetMultiBusinessRuleMailedContact(bool forceFetch, IEntityFactory entityFactoryToUse, IPredicateExpression filter)
		{
 			if( ( !_alreadyFetchedBusinessRuleMailedContact || forceFetch || _alwaysFetchBusinessRuleMailedContact) && !base.IsSerializing && !base.IsDeserializing && !EntityCollectionBase.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_businessRuleMailedContact.ParticipatesInTransaction)
					{
						base.Transaction.Add(_businessRuleMailedContact);
					}
				}
				_businessRuleMailedContact.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_businessRuleMailedContact.EntityFactoryToUse = entityFactoryToUse;
				}
				_businessRuleMailedContact.GetMultiManyToOne(null, this, filter);
				_businessRuleMailedContact.SuppressClearInGetMulti=false;
				_alreadyFetchedBusinessRuleMailedContact = true;
			}
			return _businessRuleMailedContact;
		}

		/// <summary> Sets the collection parameters for the collection for 'BusinessRuleMailedContact'. These settings will be taken into account
		/// when the property BusinessRuleMailedContact is requested or GetMultiBusinessRuleMailedContact is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersBusinessRuleMailedContact(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_businessRuleMailedContact.SortClauses=sortClauses;
			_businessRuleMailedContact.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'ContactFieldEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'ContactFieldEntity'</returns>
		public RPSDAL.CollectionClasses.ContactFieldCollection GetMultiContactField(bool forceFetch)
		{
			return GetMultiContactField(forceFetch, _contactField.EntityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'ContactFieldEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of type 'ContactFieldEntity'</returns>
		public RPSDAL.CollectionClasses.ContactFieldCollection GetMultiContactField(bool forceFetch, IPredicateExpression filter)
		{
			return GetMultiContactField(forceFetch, _contactField.EntityFactoryToUse, filter);
		}

		/// <summary> Retrieves all related entities of type 'ContactFieldEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public RPSDAL.CollectionClasses.ContactFieldCollection GetMultiContactField(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
			return GetMultiContactField(forceFetch, entityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'ContactFieldEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public virtual RPSDAL.CollectionClasses.ContactFieldCollection GetMultiContactField(bool forceFetch, IEntityFactory entityFactoryToUse, IPredicateExpression filter)
		{
 			if( ( !_alreadyFetchedContactField || forceFetch || _alwaysFetchContactField) && !base.IsSerializing && !base.IsDeserializing && !EntityCollectionBase.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_contactField.ParticipatesInTransaction)
					{
						base.Transaction.Add(_contactField);
					}
				}
				_contactField.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_contactField.EntityFactoryToUse = entityFactoryToUse;
				}
				_contactField.GetMultiManyToOne(null, this, filter);
				_contactField.SuppressClearInGetMulti=false;
				_alreadyFetchedContactField = true;
			}
			return _contactField;
		}

		/// <summary> Sets the collection parameters for the collection for 'ContactField'. These settings will be taken into account
		/// when the property ContactField is requested or GetMultiContactField is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersContactField(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_contactField.SortClauses=sortClauses;
			_contactField.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'ContactFileEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'ContactFileEntity'</returns>
		public RPSDAL.CollectionClasses.ContactFileCollection GetMultiContactFile(bool forceFetch)
		{
			return GetMultiContactFile(forceFetch, _contactFile.EntityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'ContactFileEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of type 'ContactFileEntity'</returns>
		public RPSDAL.CollectionClasses.ContactFileCollection GetMultiContactFile(bool forceFetch, IPredicateExpression filter)
		{
			return GetMultiContactFile(forceFetch, _contactFile.EntityFactoryToUse, filter);
		}

		/// <summary> Retrieves all related entities of type 'ContactFileEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public RPSDAL.CollectionClasses.ContactFileCollection GetMultiContactFile(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
			return GetMultiContactFile(forceFetch, entityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'ContactFileEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public virtual RPSDAL.CollectionClasses.ContactFileCollection GetMultiContactFile(bool forceFetch, IEntityFactory entityFactoryToUse, IPredicateExpression filter)
		{
 			if( ( !_alreadyFetchedContactFile || forceFetch || _alwaysFetchContactFile) && !base.IsSerializing && !base.IsDeserializing && !EntityCollectionBase.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_contactFile.ParticipatesInTransaction)
					{
						base.Transaction.Add(_contactFile);
					}
				}
				_contactFile.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_contactFile.EntityFactoryToUse = entityFactoryToUse;
				}
				_contactFile.GetMultiManyToOne(this, filter);
				_contactFile.SuppressClearInGetMulti=false;
				_alreadyFetchedContactFile = true;
			}
			return _contactFile;
		}

		/// <summary> Sets the collection parameters for the collection for 'ContactFile'. These settings will be taken into account
		/// when the property ContactFile is requested or GetMultiContactFile is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersContactFile(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_contactFile.SortClauses=sortClauses;
			_contactFile.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'ContactGroupMemberEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'ContactGroupMemberEntity'</returns>
		public RPSDAL.CollectionClasses.ContactGroupMemberCollection GetMultiContactGroupMember(bool forceFetch)
		{
			return GetMultiContactGroupMember(forceFetch, _contactGroupMember.EntityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'ContactGroupMemberEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of type 'ContactGroupMemberEntity'</returns>
		public RPSDAL.CollectionClasses.ContactGroupMemberCollection GetMultiContactGroupMember(bool forceFetch, IPredicateExpression filter)
		{
			return GetMultiContactGroupMember(forceFetch, _contactGroupMember.EntityFactoryToUse, filter);
		}

		/// <summary> Retrieves all related entities of type 'ContactGroupMemberEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public RPSDAL.CollectionClasses.ContactGroupMemberCollection GetMultiContactGroupMember(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
			return GetMultiContactGroupMember(forceFetch, entityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'ContactGroupMemberEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public virtual RPSDAL.CollectionClasses.ContactGroupMemberCollection GetMultiContactGroupMember(bool forceFetch, IEntityFactory entityFactoryToUse, IPredicateExpression filter)
		{
 			if( ( !_alreadyFetchedContactGroupMember || forceFetch || _alwaysFetchContactGroupMember) && !base.IsSerializing && !base.IsDeserializing && !EntityCollectionBase.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_contactGroupMember.ParticipatesInTransaction)
					{
						base.Transaction.Add(_contactGroupMember);
					}
				}
				_contactGroupMember.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_contactGroupMember.EntityFactoryToUse = entityFactoryToUse;
				}
				_contactGroupMember.GetMultiManyToOne(null, this, filter);
				_contactGroupMember.SuppressClearInGetMulti=false;
				_alreadyFetchedContactGroupMember = true;
			}
			return _contactGroupMember;
		}

		/// <summary> Sets the collection parameters for the collection for 'ContactGroupMember'. These settings will be taken into account
		/// when the property ContactGroupMember is requested or GetMultiContactGroupMember is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersContactGroupMember(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_contactGroupMember.SortClauses=sortClauses;
			_contactGroupMember.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'ContactHistoryEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'ContactHistoryEntity'</returns>
		public RPSDAL.CollectionClasses.ContactHistoryCollection GetMultiContactHistory(bool forceFetch)
		{
			return GetMultiContactHistory(forceFetch, _contactHistory.EntityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'ContactHistoryEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of type 'ContactHistoryEntity'</returns>
		public RPSDAL.CollectionClasses.ContactHistoryCollection GetMultiContactHistory(bool forceFetch, IPredicateExpression filter)
		{
			return GetMultiContactHistory(forceFetch, _contactHistory.EntityFactoryToUse, filter);
		}

		/// <summary> Retrieves all related entities of type 'ContactHistoryEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public RPSDAL.CollectionClasses.ContactHistoryCollection GetMultiContactHistory(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
			return GetMultiContactHistory(forceFetch, entityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'ContactHistoryEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public virtual RPSDAL.CollectionClasses.ContactHistoryCollection GetMultiContactHistory(bool forceFetch, IEntityFactory entityFactoryToUse, IPredicateExpression filter)
		{
 			if( ( !_alreadyFetchedContactHistory || forceFetch || _alwaysFetchContactHistory) && !base.IsSerializing && !base.IsDeserializing && !EntityCollectionBase.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_contactHistory.ParticipatesInTransaction)
					{
						base.Transaction.Add(_contactHistory);
					}
				}
				_contactHistory.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_contactHistory.EntityFactoryToUse = entityFactoryToUse;
				}
				_contactHistory.GetMultiManyToOne(null, null, this, null, filter);
				_contactHistory.SuppressClearInGetMulti=false;
				_alreadyFetchedContactHistory = true;
			}
			return _contactHistory;
		}

		/// <summary> Sets the collection parameters for the collection for 'ContactHistory'. These settings will be taken into account
		/// when the property ContactHistory is requested or GetMultiContactHistory is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersContactHistory(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_contactHistory.SortClauses=sortClauses;
			_contactHistory.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'LetterEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'LetterEntity'</returns>
		public RPSDAL.CollectionClasses.LetterCollection GetMultiLetter(bool forceFetch)
		{
			return GetMultiLetter(forceFetch, _letter.EntityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'LetterEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of type 'LetterEntity'</returns>
		public RPSDAL.CollectionClasses.LetterCollection GetMultiLetter(bool forceFetch, IPredicateExpression filter)
		{
			return GetMultiLetter(forceFetch, _letter.EntityFactoryToUse, filter);
		}

		/// <summary> Retrieves all related entities of type 'LetterEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public RPSDAL.CollectionClasses.LetterCollection GetMultiLetter(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
			return GetMultiLetter(forceFetch, entityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'LetterEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public virtual RPSDAL.CollectionClasses.LetterCollection GetMultiLetter(bool forceFetch, IEntityFactory entityFactoryToUse, IPredicateExpression filter)
		{
 			if( ( !_alreadyFetchedLetter || forceFetch || _alwaysFetchLetter) && !base.IsSerializing && !base.IsDeserializing && !EntityCollectionBase.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_letter.ParticipatesInTransaction)
					{
						base.Transaction.Add(_letter);
					}
				}
				_letter.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_letter.EntityFactoryToUse = entityFactoryToUse;
				}
				_letter.GetMultiManyToOne(null, this, filter);
				_letter.SuppressClearInGetMulti=false;
				_alreadyFetchedLetter = true;
			}
			return _letter;
		}

		/// <summary> Sets the collection parameters for the collection for 'Letter'. These settings will be taken into account
		/// when the property Letter is requested or GetMultiLetter is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersLetter(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_letter.SortClauses=sortClauses;
			_letter.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'CallEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'CallEntity'</returns>
		public RPSDAL.CollectionClasses.CallCollection GetMultiCall(bool forceFetch)
		{
			return GetMultiCall(forceFetch, _call.EntityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'CallEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of type 'CallEntity'</returns>
		public RPSDAL.CollectionClasses.CallCollection GetMultiCall(bool forceFetch, IPredicateExpression filter)
		{
			return GetMultiCall(forceFetch, _call.EntityFactoryToUse, filter);
		}

		/// <summary> Retrieves all related entities of type 'CallEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public RPSDAL.CollectionClasses.CallCollection GetMultiCall(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
			return GetMultiCall(forceFetch, entityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'CallEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public virtual RPSDAL.CollectionClasses.CallCollection GetMultiCall(bool forceFetch, IEntityFactory entityFactoryToUse, IPredicateExpression filter)
		{
 			if( ( !_alreadyFetchedCall || forceFetch || _alwaysFetchCall) && !base.IsSerializing && !base.IsDeserializing && !EntityCollectionBase.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_call.ParticipatesInTransaction)
					{
						base.Transaction.Add(_call);
					}
				}
				_call.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_call.EntityFactoryToUse = entityFactoryToUse;
				}
				_call.GetMultiManyToOne(null, this, null, filter);
				_call.SuppressClearInGetMulti=false;
				_alreadyFetchedCall = true;
			}
			return _call;
		}

		/// <summary> Sets the collection parameters for the collection for 'Call'. These settings will be taken into account
		/// when the property Call is requested or GetMultiCall is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersCall(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_call.SortClauses=sortClauses;
			_call.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'BusinessRuleEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'BusinessRuleEntity'</returns>
		public RPSDAL.CollectionClasses.BusinessRuleCollection GetMultiBusinessRuleCollectionViaBusinessRuleMailedContact(bool forceFetch)
		{
			return GetMultiBusinessRuleCollectionViaBusinessRuleMailedContact(forceFetch, _businessRuleCollectionViaBusinessRuleMailedContact.EntityFactoryToUse);
		}

		/// <summary> Retrieves all related entities of type 'BusinessRuleEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToMany() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public RPSDAL.CollectionClasses.BusinessRuleCollection GetMultiBusinessRuleCollectionViaBusinessRuleMailedContact(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
 			if( ( !_alreadyFetchedBusinessRuleCollectionViaBusinessRuleMailedContact || forceFetch || _alwaysFetchBusinessRuleCollectionViaBusinessRuleMailedContact) && !base.IsSerializing && !base.IsDeserializing && !EntityCollectionBase.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_businessRuleCollectionViaBusinessRuleMailedContact.ParticipatesInTransaction)
					{
						base.Transaction.Add(_businessRuleCollectionViaBusinessRuleMailedContact);
					}
				}
				IRelationCollection relations = new RelationCollection();
				IPredicateExpression filter = new PredicateExpression();
				relations.Add(ContactEntity.Relations.BusinessRuleMailedContactEntityUsingContactId, "BusinessRuleMailedContact_");
				relations.Add(BusinessRuleMailedContactEntity.Relations.BusinessRuleEntityUsingBusinesRuleId, "BusinessRuleMailedContact_", string.Empty, JoinHint.None);
				filter.Add(new FieldCompareValuePredicate(EntityFieldFactory.Create(ContactFieldIndex.ContactId), ComparisonOperator.Equal, this.ContactId));
				_businessRuleCollectionViaBusinessRuleMailedContact.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_businessRuleCollectionViaBusinessRuleMailedContact.EntityFactoryToUse = entityFactoryToUse;
				}
				_businessRuleCollectionViaBusinessRuleMailedContact.GetMulti(filter, relations);
				_businessRuleCollectionViaBusinessRuleMailedContact.SuppressClearInGetMulti=false;
				_alreadyFetchedBusinessRuleCollectionViaBusinessRuleMailedContact = true;
			}
			return _businessRuleCollectionViaBusinessRuleMailedContact;
		}

		/// <summary> Sets the collection parameters for the collection for 'BusinessRuleCollectionViaBusinessRuleMailedContact'. These settings will be taken into account
		/// when the property BusinessRuleCollectionViaBusinessRuleMailedContact is requested or GetMultiBusinessRuleCollectionViaBusinessRuleMailedContact is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersBusinessRuleCollectionViaBusinessRuleMailedContact(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_businessRuleCollectionViaBusinessRuleMailedContact.SortClauses=sortClauses;
			_businessRuleCollectionViaBusinessRuleMailedContact.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'ContactPageFieldEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'ContactPageFieldEntity'</returns>
		public RPSDAL.CollectionClasses.ContactPageFieldCollection GetMultiContactPageFieldCollectionViaContactField(bool forceFetch)
		{
			return GetMultiContactPageFieldCollectionViaContactField(forceFetch, _contactPageFieldCollectionViaContactField.EntityFactoryToUse);
		}

		/// <summary> Retrieves all related entities of type 'ContactPageFieldEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToMany() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public RPSDAL.CollectionClasses.ContactPageFieldCollection GetMultiContactPageFieldCollectionViaContactField(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
 			if( ( !_alreadyFetchedContactPageFieldCollectionViaContactField || forceFetch || _alwaysFetchContactPageFieldCollectionViaContactField) && !base.IsSerializing && !base.IsDeserializing && !EntityCollectionBase.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_contactPageFieldCollectionViaContactField.ParticipatesInTransaction)
					{
						base.Transaction.Add(_contactPageFieldCollectionViaContactField);
					}
				}
				IRelationCollection relations = new RelationCollection();
				IPredicateExpression filter = new PredicateExpression();
				relations.Add(ContactEntity.Relations.ContactFieldEntityUsingContactId, "ContactField_");
				relations.Add(ContactFieldEntity.Relations.ContactPageFieldEntityUsingContactPageFieldId, "ContactField_", string.Empty, JoinHint.None);
				filter.Add(new FieldCompareValuePredicate(EntityFieldFactory.Create(ContactFieldIndex.ContactId), ComparisonOperator.Equal, this.ContactId));
				_contactPageFieldCollectionViaContactField.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_contactPageFieldCollectionViaContactField.EntityFactoryToUse = entityFactoryToUse;
				}
				_contactPageFieldCollectionViaContactField.GetMulti(filter, relations);
				_contactPageFieldCollectionViaContactField.SuppressClearInGetMulti=false;
				_alreadyFetchedContactPageFieldCollectionViaContactField = true;
			}
			return _contactPageFieldCollectionViaContactField;
		}

		/// <summary> Sets the collection parameters for the collection for 'ContactPageFieldCollectionViaContactField'. These settings will be taken into account
		/// when the property ContactPageFieldCollectionViaContactField is requested or GetMultiContactPageFieldCollectionViaContactField is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersContactPageFieldCollectionViaContactField(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_contactPageFieldCollectionViaContactField.SortClauses=sortClauses;
			_contactPageFieldCollectionViaContactField.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'ContactGroupEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'ContactGroupEntity'</returns>
		public RPSDAL.CollectionClasses.ContactGroupCollection GetMultiContactGroupCollectionViaContactGroupMember(bool forceFetch)
		{
			return GetMultiContactGroupCollectionViaContactGroupMember(forceFetch, _contactGroupCollectionViaContactGroupMember.EntityFactoryToUse);
		}

		/// <summary> Retrieves all related entities of type 'ContactGroupEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToMany() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public RPSDAL.CollectionClasses.ContactGroupCollection GetMultiContactGroupCollectionViaContactGroupMember(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
 			if( ( !_alreadyFetchedContactGroupCollectionViaContactGroupMember || forceFetch || _alwaysFetchContactGroupCollectionViaContactGroupMember) && !base.IsSerializing && !base.IsDeserializing && !EntityCollectionBase.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_contactGroupCollectionViaContactGroupMember.ParticipatesInTransaction)
					{
						base.Transaction.Add(_contactGroupCollectionViaContactGroupMember);
					}
				}
				IRelationCollection relations = new RelationCollection();
				IPredicateExpression filter = new PredicateExpression();
				relations.Add(ContactEntity.Relations.ContactGroupMemberEntityUsingContactId, "ContactGroupMember_");
				relations.Add(ContactGroupMemberEntity.Relations.ContactGroupEntityUsingContactGroupId, "ContactGroupMember_", string.Empty, JoinHint.None);
				filter.Add(new FieldCompareValuePredicate(EntityFieldFactory.Create(ContactFieldIndex.ContactId), ComparisonOperator.Equal, this.ContactId));
				_contactGroupCollectionViaContactGroupMember.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_contactGroupCollectionViaContactGroupMember.EntityFactoryToUse = entityFactoryToUse;
				}
				_contactGroupCollectionViaContactGroupMember.GetMulti(filter, relations);
				_contactGroupCollectionViaContactGroupMember.SuppressClearInGetMulti=false;
				_alreadyFetchedContactGroupCollectionViaContactGroupMember = true;
			}
			return _contactGroupCollectionViaContactGroupMember;
		}

		/// <summary> Sets the collection parameters for the collection for 'ContactGroupCollectionViaContactGroupMember'. These settings will be taken into account
		/// when the property ContactGroupCollectionViaContactGroupMember is requested or GetMultiContactGroupCollectionViaContactGroupMember is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersContactGroupCollectionViaContactGroupMember(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_contactGroupCollectionViaContactGroupMember.SortClauses=sortClauses;
			_contactGroupCollectionViaContactGroupMember.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'BusinessRuleEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'BusinessRuleEntity'</returns>
		public RPSDAL.CollectionClasses.BusinessRuleCollection GetMultiBusinessRuleCollectionViaContactHistory(bool forceFetch)
		{
			return GetMultiBusinessRuleCollectionViaContactHistory(forceFetch, _businessRuleCollectionViaContactHistory.EntityFactoryToUse);
		}

		/// <summary> Retrieves all related entities of type 'BusinessRuleEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToMany() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public RPSDAL.CollectionClasses.BusinessRuleCollection GetMultiBusinessRuleCollectionViaContactHistory(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
 			if( ( !_alreadyFetchedBusinessRuleCollectionViaContactHistory || forceFetch || _alwaysFetchBusinessRuleCollectionViaContactHistory) && !base.IsSerializing && !base.IsDeserializing && !EntityCollectionBase.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_businessRuleCollectionViaContactHistory.ParticipatesInTransaction)
					{
						base.Transaction.Add(_businessRuleCollectionViaContactHistory);
					}
				}
				IRelationCollection relations = new RelationCollection();
				IPredicateExpression filter = new PredicateExpression();
				relations.Add(ContactEntity.Relations.ContactHistoryEntityUsingContactId, "ContactHistory_");
				relations.Add(ContactHistoryEntity.Relations.BusinessRuleEntityUsingBusinessRuleId, "ContactHistory_", string.Empty, JoinHint.None);
				filter.Add(new FieldCompareValuePredicate(EntityFieldFactory.Create(ContactFieldIndex.ContactId), ComparisonOperator.Equal, this.ContactId));
				_businessRuleCollectionViaContactHistory.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_businessRuleCollectionViaContactHistory.EntityFactoryToUse = entityFactoryToUse;
				}
				_businessRuleCollectionViaContactHistory.GetMulti(filter, relations);
				_businessRuleCollectionViaContactHistory.SuppressClearInGetMulti=false;
				_alreadyFetchedBusinessRuleCollectionViaContactHistory = true;
			}
			return _businessRuleCollectionViaContactHistory;
		}

		/// <summary> Sets the collection parameters for the collection for 'BusinessRuleCollectionViaContactHistory'. These settings will be taken into account
		/// when the property BusinessRuleCollectionViaContactHistory is requested or GetMultiBusinessRuleCollectionViaContactHistory is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersBusinessRuleCollectionViaContactHistory(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_businessRuleCollectionViaContactHistory.SortClauses=sortClauses;
			_businessRuleCollectionViaContactHistory.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'LetterEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'LetterEntity'</returns>
		public RPSDAL.CollectionClasses.LetterCollection GetMultiLetterCollectionViaContactHistory(bool forceFetch)
		{
			return GetMultiLetterCollectionViaContactHistory(forceFetch, _letterCollectionViaContactHistory.EntityFactoryToUse);
		}

		/// <summary> Retrieves all related entities of type 'LetterEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToMany() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public RPSDAL.CollectionClasses.LetterCollection GetMultiLetterCollectionViaContactHistory(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
 			if( ( !_alreadyFetchedLetterCollectionViaContactHistory || forceFetch || _alwaysFetchLetterCollectionViaContactHistory) && !base.IsSerializing && !base.IsDeserializing && !EntityCollectionBase.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_letterCollectionViaContactHistory.ParticipatesInTransaction)
					{
						base.Transaction.Add(_letterCollectionViaContactHistory);
					}
				}
				IRelationCollection relations = new RelationCollection();
				IPredicateExpression filter = new PredicateExpression();
				relations.Add(ContactEntity.Relations.ContactHistoryEntityUsingContactId, "ContactHistory_");
				relations.Add(ContactHistoryEntity.Relations.LetterEntityUsingLetterId, "ContactHistory_", string.Empty, JoinHint.None);
				filter.Add(new FieldCompareValuePredicate(EntityFieldFactory.Create(ContactFieldIndex.ContactId), ComparisonOperator.Equal, this.ContactId));
				_letterCollectionViaContactHistory.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_letterCollectionViaContactHistory.EntityFactoryToUse = entityFactoryToUse;
				}
				_letterCollectionViaContactHistory.GetMulti(filter, relations);
				_letterCollectionViaContactHistory.SuppressClearInGetMulti=false;
				_alreadyFetchedLetterCollectionViaContactHistory = true;
			}
			return _letterCollectionViaContactHistory;
		}

		/// <summary> Sets the collection parameters for the collection for 'LetterCollectionViaContactHistory'. These settings will be taken into account
		/// when the property LetterCollectionViaContactHistory is requested or GetMultiLetterCollectionViaContactHistory is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersLetterCollectionViaContactHistory(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_letterCollectionViaContactHistory.SortClauses=sortClauses;
			_letterCollectionViaContactHistory.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'BusinessRuleEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'BusinessRuleEntity'</returns>
		public RPSDAL.CollectionClasses.BusinessRuleCollection GetMultiBusinessRuleCollectionViaLetter(bool forceFetch)
		{
			return GetMultiBusinessRuleCollectionViaLetter(forceFetch, _businessRuleCollectionViaLetter.EntityFactoryToUse);
		}

		/// <summary> Retrieves all related entities of type 'BusinessRuleEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToMany() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public RPSDAL.CollectionClasses.BusinessRuleCollection GetMultiBusinessRuleCollectionViaLetter(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
 			if( ( !_alreadyFetchedBusinessRuleCollectionViaLetter || forceFetch || _alwaysFetchBusinessRuleCollectionViaLetter) && !base.IsSerializing && !base.IsDeserializing && !EntityCollectionBase.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_businessRuleCollectionViaLetter.ParticipatesInTransaction)
					{
						base.Transaction.Add(_businessRuleCollectionViaLetter);
					}
				}
				IRelationCollection relations = new RelationCollection();
				IPredicateExpression filter = new PredicateExpression();
				relations.Add(ContactEntity.Relations.LetterEntityUsingContactId, "Letter_");
				relations.Add(LetterEntity.Relations.BusinessRuleEntityUsingBusinessRulesId, "Letter_", string.Empty, JoinHint.None);
				filter.Add(new FieldCompareValuePredicate(EntityFieldFactory.Create(ContactFieldIndex.ContactId), ComparisonOperator.Equal, this.ContactId));
				_businessRuleCollectionViaLetter.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_businessRuleCollectionViaLetter.EntityFactoryToUse = entityFactoryToUse;
				}
				_businessRuleCollectionViaLetter.GetMulti(filter, relations);
				_businessRuleCollectionViaLetter.SuppressClearInGetMulti=false;
				_alreadyFetchedBusinessRuleCollectionViaLetter = true;
			}
			return _businessRuleCollectionViaLetter;
		}

		/// <summary> Sets the collection parameters for the collection for 'BusinessRuleCollectionViaLetter'. These settings will be taken into account
		/// when the property BusinessRuleCollectionViaLetter is requested or GetMultiBusinessRuleCollectionViaLetter is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersBusinessRuleCollectionViaLetter(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_businessRuleCollectionViaLetter.SortClauses=sortClauses;
			_businessRuleCollectionViaLetter.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'BusinessRuleEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'BusinessRuleEntity'</returns>
		public RPSDAL.CollectionClasses.BusinessRuleCollection GetMultiBusinessRuleCollectionViaCall(bool forceFetch)
		{
			return GetMultiBusinessRuleCollectionViaCall(forceFetch, _businessRuleCollectionViaCall.EntityFactoryToUse);
		}

		/// <summary> Retrieves all related entities of type 'BusinessRuleEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToMany() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public RPSDAL.CollectionClasses.BusinessRuleCollection GetMultiBusinessRuleCollectionViaCall(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
 			if( ( !_alreadyFetchedBusinessRuleCollectionViaCall || forceFetch || _alwaysFetchBusinessRuleCollectionViaCall) && !base.IsSerializing && !base.IsDeserializing && !EntityCollectionBase.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_businessRuleCollectionViaCall.ParticipatesInTransaction)
					{
						base.Transaction.Add(_businessRuleCollectionViaCall);
					}
				}
				IRelationCollection relations = new RelationCollection();
				IPredicateExpression filter = new PredicateExpression();
				relations.Add(ContactEntity.Relations.CallEntityUsingContactId, "Call_");
				relations.Add(CallEntity.Relations.BusinessRuleEntityUsingBusinessRuleId, "Call_", string.Empty, JoinHint.None);
				filter.Add(new FieldCompareValuePredicate(EntityFieldFactory.Create(ContactFieldIndex.ContactId), ComparisonOperator.Equal, this.ContactId));
				_businessRuleCollectionViaCall.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_businessRuleCollectionViaCall.EntityFactoryToUse = entityFactoryToUse;
				}
				_businessRuleCollectionViaCall.GetMulti(filter, relations);
				_businessRuleCollectionViaCall.SuppressClearInGetMulti=false;
				_alreadyFetchedBusinessRuleCollectionViaCall = true;
			}
			return _businessRuleCollectionViaCall;
		}

		/// <summary> Sets the collection parameters for the collection for 'BusinessRuleCollectionViaCall'. These settings will be taken into account
		/// when the property BusinessRuleCollectionViaCall is requested or GetMultiBusinessRuleCollectionViaCall is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersBusinessRuleCollectionViaCall(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_businessRuleCollectionViaCall.SortClauses=sortClauses;
			_businessRuleCollectionViaCall.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'UserEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'UserEntity'</returns>
		public RPSDAL.CollectionClasses.UserCollection GetMultiUserCollectionViaCall(bool forceFetch)
		{
			return GetMultiUserCollectionViaCall(forceFetch, _userCollectionViaCall.EntityFactoryToUse);
		}

		/// <summary> Retrieves all related entities of type 'UserEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToMany() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public RPSDAL.CollectionClasses.UserCollection GetMultiUserCollectionViaCall(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
 			if( ( !_alreadyFetchedUserCollectionViaCall || forceFetch || _alwaysFetchUserCollectionViaCall) && !base.IsSerializing && !base.IsDeserializing && !EntityCollectionBase.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_userCollectionViaCall.ParticipatesInTransaction)
					{
						base.Transaction.Add(_userCollectionViaCall);
					}
				}
				IRelationCollection relations = new RelationCollection();
				IPredicateExpression filter = new PredicateExpression();
				relations.Add(ContactEntity.Relations.CallEntityUsingContactId, "Call_");
				relations.Add(CallEntity.Relations.UserEntityUsingUserId, "Call_", string.Empty, JoinHint.None);
				filter.Add(new FieldCompareValuePredicate(EntityFieldFactory.Create(ContactFieldIndex.ContactId), ComparisonOperator.Equal, this.ContactId));
				_userCollectionViaCall.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_userCollectionViaCall.EntityFactoryToUse = entityFactoryToUse;
				}
				_userCollectionViaCall.GetMulti(filter, relations);
				_userCollectionViaCall.SuppressClearInGetMulti=false;
				_alreadyFetchedUserCollectionViaCall = true;
			}
			return _userCollectionViaCall;
		}

		/// <summary> Sets the collection parameters for the collection for 'UserCollectionViaCall'. These settings will be taken into account
		/// when the property UserCollectionViaCall is requested or GetMultiUserCollectionViaCall is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersUserCollectionViaCall(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_userCollectionViaCall.SortClauses=sortClauses;
			_userCollectionViaCall.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'CallEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'CallEntity'</returns>
		public RPSDAL.CollectionClasses.CallCollection GetMultiCallCollectionViaContactHistory(bool forceFetch)
		{
			return GetMultiCallCollectionViaContactHistory(forceFetch, _callCollectionViaContactHistory.EntityFactoryToUse);
		}

		/// <summary> Retrieves all related entities of type 'CallEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToMany() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public RPSDAL.CollectionClasses.CallCollection GetMultiCallCollectionViaContactHistory(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
 			if( ( !_alreadyFetchedCallCollectionViaContactHistory || forceFetch || _alwaysFetchCallCollectionViaContactHistory) && !base.IsSerializing && !base.IsDeserializing && !EntityCollectionBase.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_callCollectionViaContactHistory.ParticipatesInTransaction)
					{
						base.Transaction.Add(_callCollectionViaContactHistory);
					}
				}
				IRelationCollection relations = new RelationCollection();
				IPredicateExpression filter = new PredicateExpression();
				relations.Add(ContactEntity.Relations.ContactHistoryEntityUsingContactId, "ContactHistory_");
				relations.Add(ContactHistoryEntity.Relations.CallEntityUsingCallId, "ContactHistory_", string.Empty, JoinHint.None);
				filter.Add(new FieldCompareValuePredicate(EntityFieldFactory.Create(ContactFieldIndex.ContactId), ComparisonOperator.Equal, this.ContactId));
				_callCollectionViaContactHistory.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_callCollectionViaContactHistory.EntityFactoryToUse = entityFactoryToUse;
				}
				_callCollectionViaContactHistory.GetMulti(filter, relations);
				_callCollectionViaContactHistory.SuppressClearInGetMulti=false;
				_alreadyFetchedCallCollectionViaContactHistory = true;
			}
			return _callCollectionViaContactHistory;
		}

		/// <summary> Sets the collection parameters for the collection for 'CallCollectionViaContactHistory'. These settings will be taken into account
		/// when the property CallCollectionViaContactHistory is requested or GetMultiCallCollectionViaContactHistory is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersCallCollectionViaContactHistory(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_callCollectionViaContactHistory.SortClauses=sortClauses;
			_callCollectionViaContactHistory.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves the related entity of type 'ContactTypeEntity', using a relation of type 'n:1'</summary>
		/// <returns>A fetched entity of type 'ContactTypeEntity' which is related to this entity.</returns>
		public ContactTypeEntity GetSingleContactType()
		{
			return GetSingleContactType(false);
		}

		/// <summary> Retrieves the related entity of type 'ContactTypeEntity', using a relation of type 'n:1'</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the currently loaded related entity and will refetch the entity from the persistent storage</param>
		/// <returns>A fetched entity of type 'ContactTypeEntity' which is related to this entity.</returns>
		public virtual ContactTypeEntity GetSingleContactType(bool forceFetch)
		{
 			if( ( !_alreadyFetchedContactType || forceFetch || _alwaysFetchContactType) && !base.IsSerializing && !base.IsDeserializing )
			{

				ContactTypeEntity newEntity = new ContactTypeEntity();
				if(base.ParticipatesInTransaction)
				{
					base.Transaction.Add(newEntity);
				}
				bool fetchResult = newEntity.FetchUsingPK(this.ContactTypeId);
				if(!_contactTypeReturnsNewIfNotFound && !fetchResult)
				{
					this.ContactType = null;
				}
				else
				{
					if((base.ActiveContext!=null)&&fetchResult)
					{
						newEntity = (ContactTypeEntity)base.ActiveContext.Get(newEntity);
					}
					this.ContactType = newEntity;
					_alreadyFetchedContactType = fetchResult;
				}
				if(base.ParticipatesInTransaction && !fetchResult)
				{
					base.Transaction.Remove(newEntity);
				}
			}
			return _contactType;
		}

		/// <summary> Retrieves the related entity of type 'UserEntity', using a relation of type 'n:1'</summary>
		/// <returns>A fetched entity of type 'UserEntity' which is related to this entity.</returns>
		public UserEntity GetSingleUser()
		{
			return GetSingleUser(false);
		}

		/// <summary> Retrieves the related entity of type 'UserEntity', using a relation of type 'n:1'</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the currently loaded related entity and will refetch the entity from the persistent storage</param>
		/// <returns>A fetched entity of type 'UserEntity' which is related to this entity.</returns>
		public virtual UserEntity GetSingleUser(bool forceFetch)
		{
 			if( ( !_alreadyFetchedUser || forceFetch || _alwaysFetchUser) && !base.IsSerializing && !base.IsDeserializing )
			{

				UserEntity newEntity = new UserEntity();
				if(base.ParticipatesInTransaction)
				{
					base.Transaction.Add(newEntity);
				}
				bool fetchResult = newEntity.FetchUsingPK(this.UserId);
				if(!_userReturnsNewIfNotFound && !fetchResult)
				{
					this.User = null;
				}
				else
				{
					if((base.ActiveContext!=null)&&fetchResult)
					{
						newEntity = (UserEntity)base.ActiveContext.Get(newEntity);
					}
					this.User = newEntity;
					_alreadyFetchedUser = fetchResult;
				}
				if(base.ParticipatesInTransaction && !fetchResult)
				{
					base.Transaction.Remove(newEntity);
				}
			}
			return _user;
		}

	
		#region Data binding change event raising methods

		/// <summary> Event thrower for the ContactIdChanged event, which is thrown when ContactId changes value. Databinding related.</summary>
		protected virtual void OnContactIdChanged()
		{
			if(ContactIdChanged!=null)
			{
				ContactIdChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the ContactTypeIdChanged event, which is thrown when ContactTypeId changes value. Databinding related.</summary>
		protected virtual void OnContactTypeIdChanged()
		{
			if(ContactTypeIdChanged!=null)
			{
				ContactTypeIdChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the NameChanged event, which is thrown when Name changes value. Databinding related.</summary>
		protected virtual void OnNameChanged()
		{
			if(NameChanged!=null)
			{
				NameChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the EmailAddressChanged event, which is thrown when EmailAddress changes value. Databinding related.</summary>
		protected virtual void OnEmailAddressChanged()
		{
			if(EmailAddressChanged!=null)
			{
				EmailAddressChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the MailAddressChanged event, which is thrown when MailAddress changes value. Databinding related.</summary>
		protected virtual void OnMailAddressChanged()
		{
			if(MailAddressChanged!=null)
			{
				MailAddressChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the MailStateChanged event, which is thrown when MailState changes value. Databinding related.</summary>
		protected virtual void OnMailStateChanged()
		{
			if(MailStateChanged!=null)
			{
				MailStateChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the MailCityChanged event, which is thrown when MailCity changes value. Databinding related.</summary>
		protected virtual void OnMailCityChanged()
		{
			if(MailCityChanged!=null)
			{
				MailCityChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the MailZipChanged event, which is thrown when MailZip changes value. Databinding related.</summary>
		protected virtual void OnMailZipChanged()
		{
			if(MailZipChanged!=null)
			{
				MailZipChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the MailCountryChanged event, which is thrown when MailCountry changes value. Databinding related.</summary>
		protected virtual void OnMailCountryChanged()
		{
			if(MailCountryChanged!=null)
			{
				MailCountryChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the PhoneChanged event, which is thrown when Phone changes value. Databinding related.</summary>
		protected virtual void OnPhoneChanged()
		{
			if(PhoneChanged!=null)
			{
				PhoneChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the MobilePhoneChanged event, which is thrown when MobilePhone changes value. Databinding related.</summary>
		protected virtual void OnMobilePhoneChanged()
		{
			if(MobilePhoneChanged!=null)
			{
				MobilePhoneChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the FaxChanged event, which is thrown when Fax changes value. Databinding related.</summary>
		protected virtual void OnFaxChanged()
		{
			if(FaxChanged!=null)
			{
				FaxChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the ContactVisitDateChanged event, which is thrown when ContactVisitDate changes value. Databinding related.</summary>
		protected virtual void OnContactVisitDateChanged()
		{
			if(ContactVisitDateChanged!=null)
			{
				ContactVisitDateChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the ActiveChanged event, which is thrown when Active changes value. Databinding related.</summary>
		protected virtual void OnActiveChanged()
		{
			if(ActiveChanged!=null)
			{
				ActiveChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the UserIdChanged event, which is thrown when UserId changes value. Databinding related.</summary>
		protected virtual void OnUserIdChanged()
		{
			if(UserIdChanged!=null)
			{
				UserIdChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the SendNewsletterChanged event, which is thrown when SendNewsletter changes value. Databinding related.</summary>
		protected virtual void OnSendNewsletterChanged()
		{
			if(SendNewsletterChanged!=null)
			{
				SendNewsletterChanged(this, new EventArgs());
			}
		}

		#endregion
		
		/// <summary> Sets the field on index fieldIndex to the new value value. Marks also the fields object as dirty. </summary>
		/// <param name="fieldIndex">Index of field to set the new value of</param>
		/// <param name="value">Value to set</param>
		/// <param name="checkForRefetch">If set to true, it will check if this entity is out of sync and will refetch it first if it is. Use true in normal behavior, false for framework specific code.</param>
		/// <returns>true if the value is actually set, false otherwise.</returns>
		/// <remarks>Dereferences a related object in an 1:1/m:1 relation if the field is an FK field and responsible for the reference of that particular related object.</remarks>
		/// <exception cref="ArgumentOutOfRangeException">When fieldIndex is smaller than 0 or bigger than the number of fields in the fields collection.</exception>
		protected override bool SetNewFieldValue(int fieldIndex, object value, bool checkForRefetch)
		{
			bool toReturn = base.SetNewFieldValue (fieldIndex, value, checkForRefetch, false);
			if(toReturn && Enum.IsDefined(typeof(ContactFieldIndex), fieldIndex))
			{
				switch((ContactFieldIndex)fieldIndex)
				{
					case ContactFieldIndex.ContactTypeId:
						DecoupleEventsContactType();
						_contactType = null;
						_alreadyFetchedContactType = false;
						break;
					case ContactFieldIndex.UserId:
						DecoupleEventsUser();
						_user = null;
						_alreadyFetchedUser = false;
						break;
					default:
						break;
				}
				base.PostFieldValueSetAction(toReturn);
				switch((ContactFieldIndex)fieldIndex)
				{
					case ContactFieldIndex.ContactId:
						OnContactIdChanged();
						break;
					case ContactFieldIndex.ContactTypeId:
						OnContactTypeIdChanged();
						break;
					case ContactFieldIndex.Name:
						OnNameChanged();
						break;
					case ContactFieldIndex.EmailAddress:
						OnEmailAddressChanged();
						break;
					case ContactFieldIndex.MailAddress:
						OnMailAddressChanged();
						break;
					case ContactFieldIndex.MailState:
						OnMailStateChanged();
						break;
					case ContactFieldIndex.MailCity:
						OnMailCityChanged();
						break;
					case ContactFieldIndex.MailZip:
						OnMailZipChanged();
						break;
					case ContactFieldIndex.MailCountry:
						OnMailCountryChanged();
						break;
					case ContactFieldIndex.Phone:
						OnPhoneChanged();
						break;
					case ContactFieldIndex.MobilePhone:
						OnMobilePhoneChanged();
						break;
					case ContactFieldIndex.Fax:
						OnFaxChanged();
						break;
					case ContactFieldIndex.ContactVisitDate:
						OnContactVisitDateChanged();
						break;
					case ContactFieldIndex.Active:
						OnActiveChanged();
						break;
					case ContactFieldIndex.UserId:
						OnUserIdChanged();
						break;
					case ContactFieldIndex.SendNewsletter:
						OnSendNewsletterChanged();
						break;
					default:
						break;
				}
			}
			return toReturn;
		}

		/// <summary> Performs the insert action of a new Entity to the persistent storage.</summary>
		/// <returns>true if succeeded, false otherwise</returns>
		protected override bool InsertEntity()
		{
			ContactDAO dao = (ContactDAO)CreateDAOInstance();
			return dao.AddNew(base.Fields, base.Transaction);
		}
		
		/// <summary> Adds the internals to the active context. </summary>
		protected override void AddInternalsToContext()
		{
			_businessRuleMailedContact.ActiveContext = base.ActiveContext;
			_contactField.ActiveContext = base.ActiveContext;
			_contactFile.ActiveContext = base.ActiveContext;
			_contactGroupMember.ActiveContext = base.ActiveContext;
			_contactHistory.ActiveContext = base.ActiveContext;
			_letter.ActiveContext = base.ActiveContext;
			_call.ActiveContext = base.ActiveContext;
			_businessRuleCollectionViaBusinessRuleMailedContact.ActiveContext = base.ActiveContext;
			_contactPageFieldCollectionViaContactField.ActiveContext = base.ActiveContext;
			_contactGroupCollectionViaContactGroupMember.ActiveContext = base.ActiveContext;
			_businessRuleCollectionViaContactHistory.ActiveContext = base.ActiveContext;
			_letterCollectionViaContactHistory.ActiveContext = base.ActiveContext;
			_businessRuleCollectionViaLetter.ActiveContext = base.ActiveContext;
			_businessRuleCollectionViaCall.ActiveContext = base.ActiveContext;
			_userCollectionViaCall.ActiveContext = base.ActiveContext;
			_callCollectionViaContactHistory.ActiveContext = base.ActiveContext;
			if(_contactType!=null)
			{
				_contactType.ActiveContext = base.ActiveContext;
			}
			if(_user!=null)
			{
				_user.ActiveContext = base.ActiveContext;
			}


		}


		/// <summary> Performs the update action of an existing Entity to the persistent storage.</summary>
		/// <returns>true if succeeded, false otherwise</returns>
		protected override bool UpdateEntity()
		{
			ContactDAO dao = (ContactDAO)CreateDAOInstance();
			return dao.UpdateExisting(base.Fields, base.Transaction);
		}
		
		/// <summary> Performs the update action of an existing Entity to the persistent storage.</summary>
		/// <param name="updateRestriction">Predicate expression, meant for concurrency checks in an Update query</param>
		/// <returns>true if succeeded, false otherwise</returns>
		protected override bool UpdateEntity(IPredicate updateRestriction)
		{
			ContactDAO dao = (ContactDAO)CreateDAOInstance();
			return dao.UpdateExisting(base.Fields, base.Transaction, updateRestriction);
		}
	
		/// <summary> Initializes the class with empty data, as if it is a new Entity.</summary>
		/// <param name="propertyDescriptorFactoryToUse">PropertyDescriptor factory to use in GetItemProperties method of contained collections. Complex databinding related.</param>
		/// <param name="entityFactoryToUse">The EntityFactory to use when creating entity objects during a GetMulti() call.</param>
		/// <param name="validatorToUse">Validator to use.</param>
		protected virtual void InitClassEmpty(IPropertyDescriptorFactory propertyDescriptorFactoryToUse, IEntityFactory entityFactoryToUse, IValidator validatorToUse)
		{
			base.Fields = CreateFields();
			base.IsNew=true;
			base.EntityFactoryToUse = entityFactoryToUse;
			base.Validator = validatorToUse;

			InitClassMembers(propertyDescriptorFactoryToUse, entityFactoryToUse);
			
			// __LLBLGENPRO_USER_CODE_REGION_START InitClassEmpty
			// __LLBLGENPRO_USER_CODE_REGION_END
			

		}

		/// <summary> A method which calls all OnFieldnameChanged methods to signal that the field has been changed
		/// to bound controls. This is required after a RollbackFields() call.</summary>
		protected override void FlagAllFieldsAsChanged()
		{
			OnContactIdChanged();
			OnContactTypeIdChanged();
			OnNameChanged();
			OnEmailAddressChanged();
			OnMailAddressChanged();
			OnMailStateChanged();
			OnMailCityChanged();
			OnMailZipChanged();
			OnMailCountryChanged();
			OnPhoneChanged();
			OnMobilePhoneChanged();
			OnFaxChanged();
			OnContactVisitDateChanged();
			OnActiveChanged();
			OnUserIdChanged();
			OnSendNewsletterChanged();
		}
		
		/// <summary>Creates entity fields object for this entity. Used in constructor to setup this entity in a polymorphic scenario.</summary>
		protected virtual IEntityFields CreateFields()
		{
			return EntityFieldsFactory.CreateEntityFieldsObject(RPSDAL.EntityType.ContactEntity);
		}

		/// <summary>Creates field validator object for this entity. Used in constructor to setup this entity in a polymorphic scenario.</summary>
		protected virtual IValidator CreateValidator()
		{
			return new ContactValidator();
		}


		/// <summary> Initializes the the entity and fetches the data related to the entity in this entity.</summary>
		/// <param name="contactId">PK value for Contact which data should be fetched into this Contact object</param>
		/// <param name="propertyDescriptorFactoryToUse">PropertyDescriptor factory to use in GetItemProperties method of contained collections. Complex databinding related.</param>
		/// <param name="entityFactoryToUse">The EntityFactory to use when creating entity objects during a GetMulti() call.</param>
		/// <param name="validator">The validator object for this ContactEntity</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		protected virtual void InitClassFetch(System.Int32 contactId, IValidator validator, IPropertyDescriptorFactory propertyDescriptorFactoryToUse, IEntityFactory entityFactoryToUse, IPrefetchPath prefetchPathToUse)
		{
			InitClassMembers(propertyDescriptorFactoryToUse, entityFactoryToUse);

			base.Fields = CreateFields();
			bool wasSuccesful = Fetch(contactId, prefetchPathToUse, null);
			base.IsNew = !wasSuccesful;
			base.Validator = validator;
			base.EntityFactoryToUse = entityFactoryToUse;

			
			// __LLBLGENPRO_USER_CODE_REGION_START InitClassFetch
			// __LLBLGENPRO_USER_CODE_REGION_END
			

		}

		/// <summary> Initializes the class members</summary>
		/// <param name="propertyDescriptorFactoryToUse">PropertyDescriptor factory to use in GetItemProperties method of contained collections. Complex databinding related.</param>
		/// <param name="entityFactoryToUse">The EntityFactory to use when creating entity objects during a GetMulti() call.</param>
		private void InitClassMembers(IPropertyDescriptorFactory propertyDescriptorFactoryToUse, IEntityFactory entityFactoryToUse)
		{
			_businessRuleMailedContact = new RPSDAL.CollectionClasses.BusinessRuleMailedContactCollection(propertyDescriptorFactoryToUse, new BusinessRuleMailedContactEntityFactory());
			_businessRuleMailedContact.SetContainingEntityInfo(this, "Contact");
			_alwaysFetchBusinessRuleMailedContact = false;
			_alreadyFetchedBusinessRuleMailedContact = false;
			_contactField = new RPSDAL.CollectionClasses.ContactFieldCollection(propertyDescriptorFactoryToUse, new ContactFieldEntityFactory());
			_contactField.SetContainingEntityInfo(this, "Contact");
			_alwaysFetchContactField = false;
			_alreadyFetchedContactField = false;
			_contactFile = new RPSDAL.CollectionClasses.ContactFileCollection(propertyDescriptorFactoryToUse, new ContactFileEntityFactory());
			_contactFile.SetContainingEntityInfo(this, "Contact");
			_alwaysFetchContactFile = false;
			_alreadyFetchedContactFile = false;
			_contactGroupMember = new RPSDAL.CollectionClasses.ContactGroupMemberCollection(propertyDescriptorFactoryToUse, new ContactGroupMemberEntityFactory());
			_contactGroupMember.SetContainingEntityInfo(this, "Contact");
			_alwaysFetchContactGroupMember = false;
			_alreadyFetchedContactGroupMember = false;
			_contactHistory = new RPSDAL.CollectionClasses.ContactHistoryCollection(propertyDescriptorFactoryToUse, new ContactHistoryEntityFactory());
			_contactHistory.SetContainingEntityInfo(this, "Contact");
			_alwaysFetchContactHistory = false;
			_alreadyFetchedContactHistory = false;
			_letter = new RPSDAL.CollectionClasses.LetterCollection(propertyDescriptorFactoryToUse, new LetterEntityFactory());
			_letter.SetContainingEntityInfo(this, "Contact");
			_alwaysFetchLetter = false;
			_alreadyFetchedLetter = false;
			_call = new RPSDAL.CollectionClasses.CallCollection(propertyDescriptorFactoryToUse, new CallEntityFactory());
			_call.SetContainingEntityInfo(this, "Contact");
			_alwaysFetchCall = false;
			_alreadyFetchedCall = false;
			_businessRuleCollectionViaBusinessRuleMailedContact = new RPSDAL.CollectionClasses.BusinessRuleCollection(propertyDescriptorFactoryToUse, new BusinessRuleEntityFactory());
			_alwaysFetchBusinessRuleCollectionViaBusinessRuleMailedContact = false;
			_alreadyFetchedBusinessRuleCollectionViaBusinessRuleMailedContact = false;
			_contactPageFieldCollectionViaContactField = new RPSDAL.CollectionClasses.ContactPageFieldCollection(propertyDescriptorFactoryToUse, new ContactPageFieldEntityFactory());
			_alwaysFetchContactPageFieldCollectionViaContactField = false;
			_alreadyFetchedContactPageFieldCollectionViaContactField = false;
			_contactGroupCollectionViaContactGroupMember = new RPSDAL.CollectionClasses.ContactGroupCollection(propertyDescriptorFactoryToUse, new ContactGroupEntityFactory());
			_alwaysFetchContactGroupCollectionViaContactGroupMember = false;
			_alreadyFetchedContactGroupCollectionViaContactGroupMember = false;
			_businessRuleCollectionViaContactHistory = new RPSDAL.CollectionClasses.BusinessRuleCollection(propertyDescriptorFactoryToUse, new BusinessRuleEntityFactory());
			_alwaysFetchBusinessRuleCollectionViaContactHistory = false;
			_alreadyFetchedBusinessRuleCollectionViaContactHistory = false;
			_letterCollectionViaContactHistory = new RPSDAL.CollectionClasses.LetterCollection(propertyDescriptorFactoryToUse, new LetterEntityFactory());
			_alwaysFetchLetterCollectionViaContactHistory = false;
			_alreadyFetchedLetterCollectionViaContactHistory = false;
			_businessRuleCollectionViaLetter = new RPSDAL.CollectionClasses.BusinessRuleCollection(propertyDescriptorFactoryToUse, new BusinessRuleEntityFactory());
			_alwaysFetchBusinessRuleCollectionViaLetter = false;
			_alreadyFetchedBusinessRuleCollectionViaLetter = false;
			_businessRuleCollectionViaCall = new RPSDAL.CollectionClasses.BusinessRuleCollection(propertyDescriptorFactoryToUse, new BusinessRuleEntityFactory());
			_alwaysFetchBusinessRuleCollectionViaCall = false;
			_alreadyFetchedBusinessRuleCollectionViaCall = false;
			_userCollectionViaCall = new RPSDAL.CollectionClasses.UserCollection(propertyDescriptorFactoryToUse, new UserEntityFactory());
			_alwaysFetchUserCollectionViaCall = false;
			_alreadyFetchedUserCollectionViaCall = false;
			_callCollectionViaContactHistory = new RPSDAL.CollectionClasses.CallCollection(propertyDescriptorFactoryToUse, new CallEntityFactory());
			_alwaysFetchCallCollectionViaContactHistory = false;
			_alreadyFetchedCallCollectionViaContactHistory = false;
			_contactType = null;
			_contactTypeReturnsNewIfNotFound = true;
			_alwaysFetchContactType = false;
			_alreadyFetchedContactType = false;
			_user = null;
			_userReturnsNewIfNotFound = true;
			_alwaysFetchUser = false;
			_alreadyFetchedUser = false;

			
			// __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers
			// __LLBLGENPRO_USER_CODE_REGION_END
			
		}

		#region Custom Property Hashtable Setup
		/// <summary> Initializes the hashtables for the entity type and entity field custom properties. </summary>
		private static void SetupCustomPropertyHashtables()
		{
			_customProperties = new Hashtable();
			_fieldsCustomProperties = new Hashtable();

			Hashtable fieldHashtable = null;
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("ContactId", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("ContactTypeId", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("Name", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("EmailAddress", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("MailAddress", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("MailState", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("MailCity", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("MailZip", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("MailCountry", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("Phone", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("MobilePhone", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("Fax", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("ContactVisitDate", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("Active", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("UserId", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("SendNewsletter", fieldHashtable);
		}
		#endregion


		/// <summary> Removes the sync logic for member _contactType</summary>
		/// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param>
		private void DesetupSyncContactType(bool signalRelatedEntity)
		{
			if(_contactType != null)
			{

				_contactType.AfterSave-=new EventHandler(OnEntityAfterSave);
				base.UnsetEntitySyncInformation("ContactType", _contactType, ContactEntity.Relations.ContactTypeEntityUsingContactTypeId);
				if(signalRelatedEntity)
				{
					_contactType.UnsetRelatedEntity(this, "Contact");
				}
				SetNewFieldValue((int)ContactFieldIndex.ContactTypeId, null, false);
				_contactType = null;
			}
		}
		
		/// <summary> Decouples events from member _contactType</summary>
		private void DecoupleEventsContactType()
		{
			if(_contactType != null)
			{

				
				_contactType.AfterSave-=new EventHandler(OnEntityAfterSave);
				base.UnsetEntitySyncInformation("ContactType", _contactType, ContactEntity.Relations.ContactTypeEntityUsingContactTypeId);
			}
		}
		
		/// <summary> setups the sync logic for member _contactType</summary>
		/// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
		private void SetupSyncContactType(IEntity relatedEntity)
		{
			DesetupSyncContactType(true);
			if(relatedEntity!=null)
			{
				_contactType = (ContactTypeEntity)relatedEntity;
				_contactType.ActiveContext = base.ActiveContext;
				_alreadyFetchedContactType = true;
				_contactType.AfterSave+=new EventHandler(OnEntityAfterSave);
				base.SetEntitySyncInformation("ContactType", _contactType, ContactEntity.Relations.ContactTypeEntityUsingContactTypeId);

			}
			else
			{
				_alreadyFetchedContactType = false;
			}
		}

		/// <summary> Removes the sync logic for member _user</summary>
		/// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param>
		private void DesetupSyncUser(bool signalRelatedEntity)
		{
			if(_user != null)
			{

				_user.AfterSave-=new EventHandler(OnEntityAfterSave);
				base.UnsetEntitySyncInformation("User", _user, ContactEntity.Relations.UserEntityUsingUserId);
				if(signalRelatedEntity)
				{
					_user.UnsetRelatedEntity(this, "Contact");
				}
				SetNewFieldValue((int)ContactFieldIndex.UserId, null, false);
				_user = null;
			}
		}
		
		/// <summary> Decouples events from member _user</summary>
		private void DecoupleEventsUser()
		{
			if(_user != null)
			{

				
				_user.AfterSave-=new EventHandler(OnEntityAfterSave);
				base.UnsetEntitySyncInformation("User", _user, ContactEntity.Relations.UserEntityUsingUserId);
			}
		}
		
		/// <summary> setups the sync logic for member _user</summary>
		/// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
		private void SetupSyncUser(IEntity relatedEntity)
		{
			DesetupSyncUser(true);
			if(relatedEntity!=null)
			{
				_user = (UserEntity)relatedEntity;
				_user.ActiveContext = base.ActiveContext;
				_alreadyFetchedUser = true;
				_user.AfterSave+=new EventHandler(OnEntityAfterSave);
				base.SetEntitySyncInformation("User", _user, ContactEntity.Relations.UserEntityUsingUserId);

			}
			else
			{
				_alreadyFetchedUser = false;
			}
		}


		/// <summary> Fetches the entity from the persistent storage. Fetch simply reads the entity into an EntityFields object. </summary>
		/// <param name="contactId">PK value for Contact which data should be fetched into this Contact object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		/// <param name="contextToUse">The context to add the entity to if the fetch was succesful. </param>
		/// <returns>True if succeeded, false otherwise.</returns>
		private bool Fetch(System.Int32 contactId, IPrefetchPath prefetchPathToUse, Context contextToUse)
		{
			try
			{
				OnFetch();
				IDao dao = this.CreateDAOInstance();
				base.Fields[(int)ContactFieldIndex.ContactId].ForcedCurrentValueWrite(contactId);
				dao.FetchExisting(this, base.Transaction, prefetchPathToUse, contextToUse);
				bool fetchResult = false;
				if(base.Fields.State == EntityState.Fetched)
				{
					base.IsNew = false;
					fetchResult = true;
					if(contextToUse!=null)
					{
						base.ActiveContext = contextToUse;
						IEntity dummy = contextToUse.Get(this);
					}
				}
				return fetchResult;
			}
			finally
			{
				OnFetchComplete();
			}
		}


		/// <summary> Creates the DAO instance for this type</summary>
		/// <returns></returns>
		protected override IDao CreateDAOInstance()
		{
			return DAOFactory.CreateContactDAO();
		}
		
		/// <summary> Creates the entity factory for this type.</summary>
		/// <returns></returns>
		protected override IEntityFactory CreateEntityFactoryInstance()
		{
			return new ContactEntityFactory();
		}

		#region Class Property Declarations
		/// <summary> The relations object holding all relations of this entity with other entity classes.</summary>
		public  static ContactRelations Relations
		{
			get	{ return new ContactRelations(); }
		}
		
		/// <summary> The custom properties for this entity type.</summary>
		/// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
		public  static Hashtable CustomProperties
		{
			get { return _customProperties;}
		}


		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'BusinessRuleMailedContact' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathBusinessRuleMailedContact
		{
			get
			{
				return new PrefetchPathElement(new RPSDAL.CollectionClasses.BusinessRuleMailedContactCollection(),
					ContactEntity.Relations.BusinessRuleMailedContactEntityUsingContactId, 
					(int)RPSDAL.EntityType.ContactEntity, (int)RPSDAL.EntityType.BusinessRuleMailedContactEntity, 0, null, null, null, "BusinessRuleMailedContact", RelationType.OneToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'ContactField' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathContactField
		{
			get
			{
				return new PrefetchPathElement(new RPSDAL.CollectionClasses.ContactFieldCollection(),
					ContactEntity.Relations.ContactFieldEntityUsingContactId, 
					(int)RPSDAL.EntityType.ContactEntity, (int)RPSDAL.EntityType.ContactFieldEntity, 0, null, null, null, "ContactField", RelationType.OneToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'ContactFile' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathContactFile
		{
			get
			{
				return new PrefetchPathElement(new RPSDAL.CollectionClasses.ContactFileCollection(),
					ContactEntity.Relations.ContactFileEntityUsingContactId, 
					(int)RPSDAL.EntityType.ContactEntity, (int)RPSDAL.EntityType.ContactFileEntity, 0, null, null, null, "ContactFile", RelationType.OneToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'ContactGroupMember' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathContactGroupMember
		{
			get
			{
				return new PrefetchPathElement(new RPSDAL.CollectionClasses.ContactGroupMemberCollection(),
					ContactEntity.Relations.ContactGroupMemberEntityUsingContactId, 
					(int)RPSDAL.EntityType.ContactEntity, (int)RPSDAL.EntityType.ContactGroupMemberEntity, 0, null, null, null, "ContactGroupMember", RelationType.OneToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'ContactHistory' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathContactHistory
		{
			get
			{
				return new PrefetchPathElement(new RPSDAL.CollectionClasses.ContactHistoryCollection(),
					ContactEntity.Relations.ContactHistoryEntityUsingContactId, 
					(int)RPSDAL.EntityType.ContactEntity, (int)RPSDAL.EntityType.ContactHistoryEntity, 0, null, null, null, "ContactHistory", RelationType.OneToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'Letter' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathLetter
		{
			get
			{
				return new PrefetchPathElement(new RPSDAL.CollectionClasses.LetterCollection(),
					ContactEntity.Relations.LetterEntityUsingContactId, 
					(int)RPSDAL.EntityType.ContactEntity, (int)RPSDAL.EntityType.LetterEntity, 0, null, null, null, "Letter", RelationType.OneToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'Call' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathCall
		{
			get
			{
				return new PrefetchPathElement(new RPSDAL.CollectionClasses.CallCollection(),
					ContactEntity.Relations.CallEntityUsingContactId, 
					(int)RPSDAL.EntityType.ContactEntity, (int)RPSDAL.EntityType.CallEntity, 0, null, null, null, "Call", RelationType.OneToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'BusinessRule' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathBusinessRuleCollectionViaBusinessRuleMailedContact
		{
			get
			{
				IRelationCollection relations = new RelationCollection();
				relations.Add(ContactEntity.Relations.BusinessRuleMailedContactEntityUsingContactId);
				relations.Add(BusinessRuleMailedContactEntity.Relations.BusinessRuleEntityUsingBusinesRuleId);
				return new PrefetchPathElement(new RPSDAL.CollectionClasses.BusinessRuleCollection(),
					ContactEntity.Relations.BusinessRuleMailedContactEntityUsingContactId,
					(int)RPSDAL.EntityType.ContactEntity, (int)RPSDAL.EntityType.BusinessRuleEntity, 0, null, null, relations, "BusinessRuleCollectionViaBusinessRuleMailedContact", RelationType.ManyToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'ContactPageField' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathContactPageFieldCollectionViaContactField
		{
			get
			{
				IRelationCollection relations = new RelationCollection();
				relations.Add(ContactEntity.Relations.ContactFieldEntityUsingContactId);
				relations.Add(ContactFieldEntity.Relations.ContactPageFieldEntityUsingContactPageFieldId);
				return new PrefetchPathElement(new RPSDAL.CollectionClasses.ContactPageFieldCollection(),
					ContactEntity.Relations.ContactFieldEntityUsingContactId,
					(int)RPSDAL.EntityType.ContactEntity, (int)RPSDAL.EntityType.ContactPageFieldEntity, 0, null, null, relations, "ContactPageFieldCollectionViaContactField", RelationType.ManyToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'ContactGroup' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathContactGroupCollectionViaContactGroupMember
		{
			get
			{
				IRelationCollection relations = new RelationCollection();
				relations.Add(ContactEntity.Relations.ContactGroupMemberEntityUsingContactId);
				relations.Add(ContactGroupMemberEntity.Relations.ContactGroupEntityUsingContactGroupId);
				return new PrefetchPathElement(new RPSDAL.CollectionClasses.ContactGroupCollection(),
					ContactEntity.Relations.ContactGroupMemberEntityUsingContactId,
					(int)RPSDAL.EntityType.ContactEntity, (int)RPSDAL.EntityType.ContactGroupEntity, 0, null, null, relations, "ContactGroupCollectionViaContactGroupMember", RelationType.ManyToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'BusinessRule' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathBusinessRuleCollectionViaContactHistory
		{
			get
			{
				IRelationCollection relations = new RelationCollection();
				relations.Add(ContactEntity.Relations.ContactHistoryEntityUsingContactId);
				relations.Add(ContactHistoryEntity.Relations.BusinessRuleEntityUsingBusinessRuleId);
				return new PrefetchPathElement(new RPSDAL.CollectionClasses.BusinessRuleCollection(),
					ContactEntity.Relations.ContactHistoryEntityUsingContactId,
					(int)RPSDAL.EntityType.ContactEntity, (int)RPSDAL.EntityType.BusinessRuleEntity, 0, null, null, relations, "BusinessRuleCollectionViaContactHistory", RelationType.ManyToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'Letter' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathLetterCollectionViaContactHistory
		{
			get
			{
				IRelationCollection relations = new RelationCollection();
				relations.Add(ContactEntity.Relations.ContactHistoryEntityUsingContactId);
				relations.Add(ContactHistoryEntity.Relations.LetterEntityUsingLetterId);
				return new PrefetchPathElement(new RPSDAL.CollectionClasses.LetterCollection(),
					ContactEntity.Relations.ContactHistoryEntityUsingContactId,
					(int)RPSDAL.EntityType.ContactEntity, (int)RPSDAL.EntityType.LetterEntity, 0, null, null, relations, "LetterCollectionViaContactHistory", RelationType.ManyToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'BusinessRule' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathBusinessRuleCollectionViaLetter
		{
			get
			{
				IRelationCollection relations = new RelationCollection();
				relations.Add(ContactEntity.Relations.LetterEntityUsingContactId);
				relations.Add(LetterEntity.Relations.BusinessRuleEntityUsingBusinessRulesId);
				return new PrefetchPathElement(new RPSDAL.CollectionClasses.BusinessRuleCollection(),
					ContactEntity.Relations.LetterEntityUsingContactId,
					(int)RPSDAL.EntityType.ContactEntity, (int)RPSDAL.EntityType.BusinessRuleEntity, 0, null, null, relations, "BusinessRuleCollectionViaLetter", RelationType.ManyToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'BusinessRule' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathBusinessRuleCollectionViaCall
		{
			get
			{
				IRelationCollection relations = new RelationCollection();
				relations.Add(ContactEntity.Relations.CallEntityUsingContactId);
				relations.Add(CallEntity.Relations.BusinessRuleEntityUsingBusinessRuleId);
				return new PrefetchPathElement(new RPSDAL.CollectionClasses.BusinessRuleCollection(),
					ContactEntity.Relations.CallEntityUsingContactId,
					(int)RPSDAL.EntityType.ContactEntity, (int)RPSDAL.EntityType.BusinessRuleEntity, 0, null, null, relations, "BusinessRuleCollectionViaCall", RelationType.ManyToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'User' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathUserCollectionViaCall
		{
			get
			{
				IRelationCollection relations = new RelationCollection();
				relations.Add(ContactEntity.Relations.CallEntityUsingContactId);
				relations.Add(CallEntity.Relations.UserEntityUsingUserId);
				return new PrefetchPathElement(new RPSDAL.CollectionClasses.UserCollection(),
					ContactEntity.Relations.CallEntityUsingContactId,
					(int)RPSDAL.EntityType.ContactEntity, (int)RPSDAL.EntityType.UserEntity, 0, null, null, relations, "UserCollectionViaCall", RelationType.ManyToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'Call' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathCallCollectionViaContactHistory
		{
			get
			{
				IRelationCollection relations = new RelationCollection();
				relations.Add(ContactEntity.Relations.ContactHistoryEntityUsingContactId);
				relations.Add(ContactHistoryEntity.Relations.CallEntityUsingCallId);
				return new PrefetchPathElement(new RPSDAL.CollectionClasses.CallCollection(),
					ContactEntity.Relations.ContactHistoryEntityUsingContactId,
					(int)RPSDAL.EntityType.ContactEntity, (int)RPSDAL.EntityType.CallEntity, 0, null, null, relations, "CallCollectionViaContactHistory", RelationType.ManyToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'ContactType' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathContactType
		{
			get
			{
				return new PrefetchPathElement(new RPSDAL.CollectionClasses.ContactTypeCollection(),
					ContactEntity.Relations.ContactTypeEntityUsingContactTypeId, 
					(int)RPSDAL.EntityType.ContactEntity, (int)RPSDAL.EntityType.ContactTypeEntity, 0, null, null, null, "ContactType", RelationType.ManyToOne);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'User' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathUser
		{
			get
			{
				return new PrefetchPathElement(new RPSDAL.CollectionClasses.UserCollection(),
					ContactEntity.Relations.UserEntityUsingUserId, 
					(int)RPSDAL.EntityType.ContactEntity, (int)RPSDAL.EntityType.UserEntity, 0, null, null, null, "User", RelationType.ManyToOne);
			}
		}


		/// <summary> The custom properties for the type of this entity instance.</summary>
		/// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
		[Browsable(false), XmlIgnore]
		public virtual Hashtable CustomPropertiesOfType
		{
			get { return ContactEntity.CustomProperties;}
		}

		/// <summary> The custom properties for the fields of this entity type. The returned Hashtable contains per fieldname a hashtable of name-value pairs. </summary>
		/// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
		public  static Hashtable FieldsCustomProperties
		{
			get { return _fieldsCustomProperties;}
		}

		/// <summary> The custom properties for the fields of the type of this entity instance. The returned Hashtable contains per fieldname a hashtable of name-value pairs. </summary>
		/// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
		[Browsable(false), XmlIgnore]
		public virtual Hashtable FieldsCustomPropertiesOfType
		{
			get { return ContactEntity.FieldsCustomProperties;}
		}

		/// <summary> The ContactId property of the Entity Contact<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Contact"."ContactId"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): false, true, true</remarks>
		public virtual System.Int32 ContactId
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)ContactFieldIndex.ContactId);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.Int32));
				}
				return (System.Int32)valueToReturn;
			}
			set	{ SetNewFieldValue((int)ContactFieldIndex.ContactId, value); }
		}
		/// <summary> The ContactTypeId property of the Entity Contact<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Contact"."ContactTypeId"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.Int32 ContactTypeId
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)ContactFieldIndex.ContactTypeId);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.Int32));
				}
				return (System.Int32)valueToReturn;
			}
			set	{ SetNewFieldValue((int)ContactFieldIndex.ContactTypeId, value); }
		}
		/// <summary> The Name property of the Entity Contact<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Contact"."Name"<br/>
		/// Table field type characteristics (type, precision, scale, length): VarChar, 0, 0, 255<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String Name
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)ContactFieldIndex.Name);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.String));
				}
				return (System.String)valueToReturn;
			}
			set	{ SetNewFieldValue((int)ContactFieldIndex.Name, value); }
		}
		/// <summary> The EmailAddress property of the Entity Contact<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Contact"."EmailAddress"<br/>
		/// Table field type characteristics (type, precision, scale, length): VarChar, 0, 0, 255<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String EmailAddress
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)ContactFieldIndex.EmailAddress);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.String));
				}
				return (System.String)valueToReturn;
			}
			set	{ SetNewFieldValue((int)ContactFieldIndex.EmailAddress, value); }
		}
		/// <summary> The MailAddress property of the Entity Contact<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Contact"."MailAddress"<br/>
		/// Table field type characteristics (type, precision, scale, length): Text, 0, 0, 2147483647<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String MailAddress
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)ContactFieldIndex.MailAddress);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.String));
				}
				return (System.String)valueToReturn;
			}
			set	{ SetNewFieldValue((int)ContactFieldIndex.MailAddress, value); }
		}
		/// <summary> The MailState property of the Entity Contact<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Contact"."MailState"<br/>
		/// Table field type characteristics (type, precision, scale, length): VarChar, 0, 0, 255<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String MailState
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)ContactFieldIndex.MailState);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.String));
				}
				return (System.String)valueToReturn;
			}
			set	{ SetNewFieldValue((int)ContactFieldIndex.MailState, value); }
		}
		/// <summary> The MailCity property of the Entity Contact<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Contact"."MailCity"<br/>
		/// Table field type characteristics (type, precision, scale, length): VarChar, 0, 0, 255<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String MailCity
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)ContactFieldIndex.MailCity);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.String));
				}
				return (System.String)valueToReturn;
			}
			set	{ SetNewFieldValue((int)ContactFieldIndex.MailCity, value); }
		}
		/// <summary> The MailZip property of the Entity Contact<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Contact"."MailZip"<br/>
		/// Table field type characteristics (type, precision, scale, length): VarChar, 0, 0, 255<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String MailZip
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)ContactFieldIndex.MailZip);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.String));
				}
				return (System.String)valueToReturn;
			}
			set	{ SetNewFieldValue((int)ContactFieldIndex.MailZip, value); }
		}
		/// <summary> The MailCountry property of the Entity Contact<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Contact"."MailCountry"<br/>
		/// Table field type characteristics (type, precision, scale, length): VarChar, 0, 0, 255<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String MailCountry
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)ContactFieldIndex.MailCountry);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.String));
				}
				return (System.String)valueToReturn;
			}
			set	{ SetNewFieldValue((int)ContactFieldIndex.MailCountry, value); }
		}
		/// <summary> The Phone property of the Entity Contact<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Contact"."Phone"<br/>
		/// Table field type characteristics (type, precision, scale, length): VarChar, 0, 0, 255<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String Phone
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)ContactFieldIndex.Phone);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.String));
				}
				return (System.String)valueToReturn;
			}
			set	{ SetNewFieldValue((int)ContactFieldIndex.Phone, value); }
		}
		/// <summary> The MobilePhone property of the Entity Contact<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Contact"."MobilePhone"<br/>
		/// Table field type characteristics (type, precision, scale, length): VarChar, 0, 0, 255<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String MobilePhone
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)ContactFieldIndex.MobilePhone);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.String));
				}
				return (System.String)valueToReturn;
			}
			set	{ SetNewFieldValue((int)ContactFieldIndex.MobilePhone, value); }
		}
		/// <summary> The Fax property of the Entity Contact<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Contact"."Fax"<br/>
		/// Table field type characteristics (type, precision, scale, length): VarChar, 0, 0, 255<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String Fax
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)ContactFieldIndex.Fax);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.String));
				}
				return (System.String)valueToReturn;
			}
			set	{ SetNewFieldValue((int)ContactFieldIndex.Fax, value); }
		}
		/// <summary> The ContactVisitDate property of the Entity Contact<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Contact"."ContactVisitDate"<br/>
		/// Table field type characteristics (type, precision, scale, length): DateTime, 0, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.DateTime ContactVisitDate
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)ContactFieldIndex.ContactVisitDate);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.DateTime));
				}
				return (System.DateTime)valueToReturn;
			}
			set	{ SetNewFieldValue((int)ContactFieldIndex.ContactVisitDate, value); }
		}
		/// <summary> The Active property of the Entity Contact<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Contact"."Active"<br/>
		/// Table field type characteristics (type, precision, scale, length): Bit, 0, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.Boolean Active
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)ContactFieldIndex.Active);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.Boolean));
				}
				return (System.Boolean)valueToReturn;
			}
			set	{ SetNewFieldValue((int)ContactFieldIndex.Active, value); }
		}
		/// <summary> The UserId property of the Entity Contact<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Contact"."UserId"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.Int32 UserId
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)ContactFieldIndex.UserId);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.Int32));
				}
				return (System.Int32)valueToReturn;
			}
			set	{ SetNewFieldValue((int)ContactFieldIndex.UserId, value); }
		}
		/// <summary> The SendNewsletter property of the Entity Contact<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Contact"."SendNewsletter"<br/>
		/// Table field type characteristics (type, precision, scale, length): Bit, 0, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.Boolean SendNewsletter
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)ContactFieldIndex.SendNewsletter);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.Boolean));
				}
				return (System.Boolean)valueToReturn;
			}
			set	{ SetNewFieldValue((int)ContactFieldIndex.SendNewsletter, value); }
		}

		/// <summary> Retrieves all related entities of type 'BusinessRuleMailedContactEntity' using a relation of type '1:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiBusinessRuleMailedContact()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual RPSDAL.CollectionClasses.BusinessRuleMailedContactCollection BusinessRuleMailedContact
		{
			get	{ return GetMultiBusinessRuleMailedContact(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for BusinessRuleMailedContact. When set to true, BusinessRuleMailedContact is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time BusinessRuleMailedContact is accessed. You can always execute
		/// a forced fetch by calling GetMultiBusinessRuleMailedContact(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchBusinessRuleMailedContact
		{
			get	{ return _alwaysFetchBusinessRuleMailedContact; }
			set	{ _alwaysFetchBusinessRuleMailedContact = value; }	
		}
		/// <summary> Retrieves all related entities of type 'ContactFieldEntity' using a relation of type '1:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiContactField()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual RPSDAL.CollectionClasses.ContactFieldCollection ContactField
		{
			get	{ return GetMultiContactField(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for ContactField. When set to true, ContactField is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time ContactField is accessed. You can always execute
		/// a forced fetch by calling GetMultiContactField(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchContactField
		{
			get	{ return _alwaysFetchContactField; }
			set	{ _alwaysFetchContactField = value; }	
		}
		/// <summary> Retrieves all related entities of type 'ContactFileEntity' using a relation of type '1:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiContactFile()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual RPSDAL.CollectionClasses.ContactFileCollection ContactFile
		{
			get	{ return GetMultiContactFile(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for ContactFile. When set to true, ContactFile is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time ContactFile is accessed. You can always execute
		/// a forced fetch by calling GetMultiContactFile(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchContactFile
		{
			get	{ return _alwaysFetchContactFile; }
			set	{ _alwaysFetchContactFile = value; }	
		}
		/// <summary> Retrieves all related entities of type 'ContactGroupMemberEntity' using a relation of type '1:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiContactGroupMember()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual RPSDAL.CollectionClasses.ContactGroupMemberCollection ContactGroupMember
		{
			get	{ return GetMultiContactGroupMember(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for ContactGroupMember. When set to true, ContactGroupMember is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time ContactGroupMember is accessed. You can always execute
		/// a forced fetch by calling GetMultiContactGroupMember(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchContactGroupMember
		{
			get	{ return _alwaysFetchContactGroupMember; }
			set	{ _alwaysFetchContactGroupMember = value; }	
		}
		/// <summary> Retrieves all related entities of type 'ContactHistoryEntity' using a relation of type '1:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiContactHistory()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual RPSDAL.CollectionClasses.ContactHistoryCollection ContactHistory
		{
			get	{ return GetMultiContactHistory(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for ContactHistory. When set to true, ContactHistory is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time ContactHistory is accessed. You can always execute
		/// a forced fetch by calling GetMultiContactHistory(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchContactHistory
		{
			get	{ return _alwaysFetchContactHistory; }
			set	{ _alwaysFetchContactHistory = value; }	
		}
		/// <summary> Retrieves all related entities of type 'LetterEntity' using a relation of type '1:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiLetter()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual RPSDAL.CollectionClasses.LetterCollection Letter
		{
			get	{ return GetMultiLetter(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for Letter. When set to true, Letter is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time Letter is accessed. You can always execute
		/// a forced fetch by calling GetMultiLetter(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchLetter
		{
			get	{ return _alwaysFetchLetter; }
			set	{ _alwaysFetchLetter = value; }	
		}
		/// <summary> Retrieves all related entities of type 'CallEntity' using a relation of type '1:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiCall()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual RPSDAL.CollectionClasses.CallCollection Call
		{
			get	{ return GetMultiCall(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for Call. When set to true, Call is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time Call is accessed. You can always execute
		/// a forced fetch by calling GetMultiCall(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchCall
		{
			get	{ return _alwaysFetchCall; }
			set	{ _alwaysFetchCall = value; }	
		}

		/// <summary> Retrieves all related entities of type 'BusinessRuleEntity' using a relation of type 'm:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiBusinessRuleCollectionViaBusinessRuleMailedContact()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual RPSDAL.CollectionClasses.BusinessRuleCollection BusinessRuleCollectionViaBusinessRuleMailedContact
		{
			get { return GetMultiBusinessRuleCollectionViaBusinessRuleMailedContact(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for BusinessRuleCollectionViaBusinessRuleMailedContact. When set to true, BusinessRuleCollectionViaBusinessRuleMailedContact is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time BusinessRuleCollectionViaBusinessRuleMailedContact is accessed. You can always execute
		/// a forced fetch by calling GetMultiBusinessRuleCollectionViaBusinessRuleMailedContact(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchBusinessRuleCollectionViaBusinessRuleMailedContact
		{
			get	{ return _alwaysFetchBusinessRuleCollectionViaBusinessRuleMailedContact; }
			set	{ _alwaysFetchBusinessRuleCollectionViaBusinessRuleMailedContact = value; }	
		}
		/// <summary> Retrieves all related entities of type 'ContactPageFieldEntity' using a relation of type 'm:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiContactPageFieldCollectionViaContactField()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual RPSDAL.CollectionClasses.ContactPageFieldCollection ContactPageFieldCollectionViaContactField
		{
			get { return GetMultiContactPageFieldCollectionViaContactField(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for ContactPageFieldCollectionViaContactField. When set to true, ContactPageFieldCollectionViaContactField is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time ContactPageFieldCollectionViaContactField is accessed. You can always execute
		/// a forced fetch by calling GetMultiContactPageFieldCollectionViaContactField(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchContactPageFieldCollectionViaContactField
		{
			get	{ return _alwaysFetchContactPageFieldCollectionViaContactField; }
			set	{ _alwaysFetchContactPageFieldCollectionViaContactField = value; }	
		}
		/// <summary> Retrieves all related entities of type 'ContactGroupEntity' using a relation of type 'm:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiContactGroupCollectionViaContactGroupMember()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual RPSDAL.CollectionClasses.ContactGroupCollection ContactGroupCollectionViaContactGroupMember
		{
			get { return GetMultiContactGroupCollectionViaContactGroupMember(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for ContactGroupCollectionViaContactGroupMember. When set to true, ContactGroupCollectionViaContactGroupMember is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time ContactGroupCollectionViaContactGroupMember is accessed. You can always execute
		/// a forced fetch by calling GetMultiContactGroupCollectionViaContactGroupMember(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchContactGroupCollectionViaContactGroupMember
		{
			get	{ return _alwaysFetchContactGroupCollectionViaContactGroupMember; }
			set	{ _alwaysFetchContactGroupCollectionViaContactGroupMember = value; }	
		}
		/// <summary> Retrieves all related entities of type 'BusinessRuleEntity' using a relation of type 'm:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiBusinessRuleCollectionViaContactHistory()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual RPSDAL.CollectionClasses.BusinessRuleCollection BusinessRuleCollectionViaContactHistory
		{
			get { return GetMultiBusinessRuleCollectionViaContactHistory(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for BusinessRuleCollectionViaContactHistory. When set to true, BusinessRuleCollectionViaContactHistory is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time BusinessRuleCollectionViaContactHistory is accessed. You can always execute
		/// a forced fetch by calling GetMultiBusinessRuleCollectionViaContactHistory(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchBusinessRuleCollectionViaContactHistory
		{
			get	{ return _alwaysFetchBusinessRuleCollectionViaContactHistory; }
			set	{ _alwaysFetchBusinessRuleCollectionViaContactHistory = value; }	
		}
		/// <summary> Retrieves all related entities of type 'LetterEntity' using a relation of type 'm:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiLetterCollectionViaContactHistory()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual RPSDAL.CollectionClasses.LetterCollection LetterCollectionViaContactHistory
		{
			get { return GetMultiLetterCollectionViaContactHistory(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for LetterCollectionViaContactHistory. When set to true, LetterCollectionViaContactHistory is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time LetterCollectionViaContactHistory is accessed. You can always execute
		/// a forced fetch by calling GetMultiLetterCollectionViaContactHistory(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchLetterCollectionViaContactHistory
		{
			get	{ return _alwaysFetchLetterCollectionViaContactHistory; }
			set	{ _alwaysFetchLetterCollectionViaContactHistory = value; }	
		}
		/// <summary> Retrieves all related entities of type 'BusinessRuleEntity' using a relation of type 'm:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiBusinessRuleCollectionViaLetter()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual RPSDAL.CollectionClasses.BusinessRuleCollection BusinessRuleCollectionViaLetter
		{
			get { return GetMultiBusinessRuleCollectionViaLetter(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for BusinessRuleCollectionViaLetter. When set to true, BusinessRuleCollectionViaLetter is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time BusinessRuleCollectionViaLetter is accessed. You can always execute
		/// a forced fetch by calling GetMultiBusinessRuleCollectionViaLetter(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchBusinessRuleCollectionViaLetter
		{
			get	{ return _alwaysFetchBusinessRuleCollectionViaLetter; }
			set	{ _alwaysFetchBusinessRuleCollectionViaLetter = value; }	
		}
		/// <summary> Retrieves all related entities of type 'BusinessRuleEntity' using a relation of type 'm:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiBusinessRuleCollectionViaCall()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual RPSDAL.CollectionClasses.BusinessRuleCollection BusinessRuleCollectionViaCall
		{
			get { return GetMultiBusinessRuleCollectionViaCall(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for BusinessRuleCollectionViaCall. When set to true, BusinessRuleCollectionViaCall is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time BusinessRuleCollectionViaCall is accessed. You can always execute
		/// a forced fetch by calling GetMultiBusinessRuleCollectionViaCall(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchBusinessRuleCollectionViaCall
		{
			get	{ return _alwaysFetchBusinessRuleCollectionViaCall; }
			set	{ _alwaysFetchBusinessRuleCollectionViaCall = value; }	
		}
		/// <summary> Retrieves all related entities of type 'UserEntity' using a relation of type 'm:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiUserCollectionViaCall()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual RPSDAL.CollectionClasses.UserCollection UserCollectionViaCall
		{
			get { return GetMultiUserCollectionViaCall(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for UserCollectionViaCall. When set to true, UserCollectionViaCall is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time UserCollectionViaCall is accessed. You can always execute
		/// a forced fetch by calling GetMultiUserCollectionViaCall(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchUserCollectionViaCall
		{
			get	{ return _alwaysFetchUserCollectionViaCall; }
			set	{ _alwaysFetchUserCollectionViaCall = value; }	
		}
		/// <summary> Retrieves all related entities of type 'CallEntity' using a relation of type 'm:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiCallCollectionViaContactHistory()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual RPSDAL.CollectionClasses.CallCollection CallCollectionViaContactHistory
		{
			get { return GetMultiCallCollectionViaContactHistory(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for CallCollectionViaContactHistory. When set to true, CallCollectionViaContactHistory is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time CallCollectionViaContactHistory is accessed. You can always execute
		/// a forced fetch by calling GetMultiCallCollectionViaContactHistory(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchCallCollectionViaContactHistory
		{
			get	{ return _alwaysFetchCallCollectionViaContactHistory; }
			set	{ _alwaysFetchCallCollectionViaContactHistory = value; }	
		}

		/// <summary> Gets / sets related entity of type 'ContactTypeEntity'. This property is not visible in databound grids.
		/// Setting this property to a new object will make the load-on-demand feature to stop fetching data from the database, until you set this
		/// property to null. Setting this property to an entity will make sure that FK-PK relations are synchronized when appropriate.</summary>
		/// <remarks>This property is added for conveniance, however it is recommeded to use the method 'GetSingleContactType()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the
		/// same scope. The property is marked non-browsable to make it hidden in bound controls, f.e. datagrids.</remarks>
		[Browsable(false)]
		public virtual ContactTypeEntity ContactType
		{
			get	{ return GetSingleContactType(false); }
			set
			{
				if(base.IsDeserializing)
				{
					SetupSyncContactType(value);
				}
				else
				{
					if(value==null)
					{
						if(_contactType != null)
						{
							_contactType.UnsetRelatedEntity(this, "Contact");
						}
					}
					else
					{
						((IEntity)value).SetRelatedEntity(this, "Contact");
					}
				}
			}
		}

		/// <summary> Gets / sets the lazy loading flag for ContactType. When set to true, ContactType is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time ContactType is accessed. You can always execute
		/// a forced fetch by calling GetSingleContactType(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchContactType
		{
			get	{ return _alwaysFetchContactType; }
			set	{ _alwaysFetchContactType = value; }	
		}
		
		/// <summary> Gets / sets the flag for what to do if the related entity available through the property ContactType is not found
		/// in the database. When set to true, ContactType will return a new entity instance if the related entity is not found, otherwise 
		/// null be returned if the related entity is not found. Default: true.</summary>
		[Browsable(false)]
		public bool ContactTypeReturnsNewIfNotFound
		{
			get	{ return _contactTypeReturnsNewIfNotFound; }
			set { _contactTypeReturnsNewIfNotFound = value; }	
		}
		/// <summary> Gets / sets related entity of type 'UserEntity'. This property is not visible in databound grids.
		/// Setting this property to a new object will make the load-on-demand feature to stop fetching data from the database, until you set this
		/// property to null. Setting this property to an entity will make sure that FK-PK relations are synchronized when appropriate.</summary>
		/// <remarks>This property is added for conveniance, however it is recommeded to use the method 'GetSingleUser()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the
		/// same scope. The property is marked non-browsable to make it hidden in bound controls, f.e. datagrids.</remarks>
		[Browsable(false)]
		public virtual UserEntity User
		{
			get	{ return GetSingleUser(false); }
			set
			{
				if(base.IsDeserializing)
				{
					SetupSyncUser(value);
				}
				else
				{
					if(value==null)
					{
						if(_user != null)
						{
							_user.UnsetRelatedEntity(this, "Contact");
						}
					}
					else
					{
						((IEntity)value).SetRelatedEntity(this, "Contact");
					}
				}
			}
		}

		/// <summary> Gets / sets the lazy loading flag for User. When set to true, User is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time User is accessed. You can always execute
		/// a forced fetch by calling GetSingleUser(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchUser
		{
			get	{ return _alwaysFetchUser; }
			set	{ _alwaysFetchUser = value; }	
		}
		
		/// <summary> Gets / sets the flag for what to do if the related entity available through the property User is not found
		/// in the database. When set to true, User will return a new entity instance if the related entity is not found, otherwise 
		/// null be returned if the related entity is not found. Default: true.</summary>
		[Browsable(false)]
		public bool UserReturnsNewIfNotFound
		{
			get	{ return _userReturnsNewIfNotFound; }
			set { _userReturnsNewIfNotFound = value; }	
		}



		/// <summary> Gets or sets a value indicating whether this entity is a subtype</summary>
		protected override bool LLBLGenProIsSubType
		{
			get { return false;}
		}

		/// <summary> Gets the type of the hierarchy this entity is in. </summary>
		[System.ComponentModel.Browsable(false), XmlIgnore]
		protected override InheritanceHierarchyType LLBLGenProIsInHierarchyOfType
		{
			get { return InheritanceHierarchyType.None;}
		}
		
		/// <summary>Returns the EntityType enum value for this entity.</summary>
		[Browsable(false), XmlIgnore]
		public override int LLBLGenProEntityTypeValue 
		{ 
			get { return (int)RPSDAL.EntityType.ContactEntity; }
		}
		#endregion

		
		#region Custom Entity code
		
		// __LLBLGENPRO_USER_CODE_REGION_START CustomEntityCode
		// __LLBLGENPRO_USER_CODE_REGION_END
		
		#endregion

		#region Included code

		#endregion
	}
}
